| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Base class that represents a row from the 'article' table.
|
|
|
5 |
*
|
|
|
6 |
*
|
|
|
7 |
*
|
|
|
8 |
* This class was autogenerated by Propel 1.4.2 on:
|
|
|
9 |
*
|
|
|
10 |
* Fri Aug 5 09:39:36 2011
|
|
|
11 |
*
|
|
|
12 |
* @package lib.model.om
|
|
|
13 |
*/
|
|
|
14 |
abstract class BaseArticle extends BaseObject implements Persistent {
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* The Peer class.
|
|
|
19 |
* Instance provides a convenient way of calling static methods on a class
|
|
|
20 |
* that calling code may not be able to identify.
|
|
|
21 |
* @var ArticlePeer
|
|
|
22 |
*/
|
|
|
23 |
protected static $peer;
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* The value for the id field.
|
|
|
27 |
* @var int
|
|
|
28 |
*/
|
|
|
29 |
protected $id;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* The value for the title field.
|
|
|
33 |
* @var string
|
|
|
34 |
*/
|
|
|
35 |
protected $title;
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* The value for the body field.
|
|
|
39 |
* @var string
|
|
|
40 |
*/
|
|
|
41 |
protected $body;
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* The value for the online field.
|
|
|
45 |
* @var boolean
|
|
|
46 |
*/
|
|
|
47 |
protected $online;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
* The value for the excerpt field.
|
|
|
51 |
* @var string
|
|
|
52 |
*/
|
|
|
53 |
protected $excerpt;
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* The value for the category_id field.
|
|
|
57 |
* @var int
|
|
|
58 |
*/
|
|
|
59 |
protected $category_id;
|
|
|
60 |
|
|
|
61 |
/**
|
|
|
62 |
* The value for the created_at field.
|
|
|
63 |
* @var string
|
|
|
64 |
*/
|
|
|
65 |
protected $created_at;
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* The value for the end_date field.
|
|
|
69 |
* @var string
|
|
|
70 |
*/
|
|
|
71 |
protected $end_date;
|
|
|
72 |
|
|
|
73 |
/**
|
|
|
74 |
* The value for the book_id field.
|
|
|
75 |
* @var int
|
|
|
76 |
*/
|
|
|
77 |
protected $book_id;
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* @var Category
|
|
|
81 |
*/
|
|
|
82 |
protected $aCategory;
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* @var Book
|
|
|
86 |
*/
|
|
|
87 |
protected $aBook;
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* @var array AuthorArticle[] Collection to store aggregation of AuthorArticle objects.
|
|
|
91 |
*/
|
|
|
92 |
protected $collAuthorArticles;
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* @var Criteria The criteria used to select the current contents of collAuthorArticles.
|
|
|
96 |
*/
|
|
|
97 |
private $lastAuthorArticleCriteria = null;
|
|
|
98 |
|
|
|
99 |
/**
|
|
|
100 |
* @var array Attachment[] Collection to store aggregation of Attachment objects.
|
|
|
101 |
*/
|
|
|
102 |
protected $collAttachments;
|
|
|
103 |
|
|
|
104 |
/**
|
|
|
105 |
* @var Criteria The criteria used to select the current contents of collAttachments.
|
|
|
106 |
*/
|
|
|
107 |
private $lastAttachmentCriteria = null;
|
|
|
108 |
|
|
|
109 |
/**
|
|
|
110 |
* Flag to prevent endless save loop, if this object is referenced
|
|
|
111 |
* by another object which falls in this transaction.
|
|
|
112 |
* @var boolean
|
|
|
113 |
*/
|
|
|
114 |
protected $alreadyInSave = false;
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
* Flag to prevent endless validation loop, if this object is referenced
|
|
|
118 |
* by another object which falls in this transaction.
|
|
|
119 |
* @var boolean
|
|
|
120 |
*/
|
|
|
121 |
protected $alreadyInValidation = false;
|
|
|
122 |
|
|
|
123 |
// symfony behavior
|
|
|
124 |
|
|
|
125 |
const PEER = 'ArticlePeer';
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Get the [id] column value.
|
|
|
129 |
*
|
|
|
130 |
* @return int
|
|
|
131 |
*/
|
|
|
132 |
public function getId()
|
|
|
133 |
{
|
|
|
134 |
return $this->id;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
/**
|
|
|
138 |
* Get the [title] column value.
|
|
|
139 |
*
|
|
|
140 |
* @return string
|
|
|
141 |
*/
|
|
|
142 |
public function getTitle()
|
|
|
143 |
{
|
|
|
144 |
return $this->title;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
/**
|
|
|
148 |
* Get the [body] column value.
|
|
|
149 |
*
|
|
|
150 |
* @return string
|
|
|
151 |
*/
|
|
|
152 |
public function getBody()
|
|
|
153 |
{
|
|
|
154 |
return $this->body;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
/**
|
|
|
158 |
* Get the [online] column value.
|
|
|
159 |
*
|
|
|
160 |
* @return boolean
|
|
|
161 |
*/
|
|
|
162 |
public function getOnline()
|
|
|
163 |
{
|
|
|
164 |
return $this->online;
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
/**
|
|
|
168 |
* Get the [excerpt] column value.
|
|
|
169 |
*
|
|
|
170 |
* @return string
|
|
|
171 |
*/
|
|
|
172 |
public function getExcerpt()
|
|
|
173 |
{
|
|
|
174 |
return $this->excerpt;
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
/**
|
|
|
178 |
* Get the [category_id] column value.
|
|
|
179 |
*
|
|
|
180 |
* @return int
|
|
|
181 |
*/
|
|
|
182 |
public function getCategoryId()
|
|
|
183 |
{
|
|
|
184 |
return $this->category_id;
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
/**
|
|
|
188 |
* Get the [optionally formatted] temporal [created_at] column value.
|
|
|
189 |
*
|
|
|
190 |
*
|
|
|
191 |
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
|
192 |
* If format is NULL, then the raw DateTime object will be returned.
|
|
|
193 |
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
|
|
194 |
* @throws PropelException - if unable to parse/validate the date/time value.
|
|
|
195 |
*/
|
|
|
196 |
public function getCreatedAt($format = 'Y-m-d H:i:s')
|
|
|
197 |
{
|
|
|
198 |
if ($this->created_at === null) {
|
|
|
199 |
return null;
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
try {
|
|
|
205 |
$dt = new DateTime($this->created_at);
|
|
|
206 |
} catch (Exception $x) {
|
|
|
207 |
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
if ($format === null) {
|
|
|
211 |
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
|
212 |
return $dt;
|
|
|
213 |
} elseif (strpos($format, '%') !== false) {
|
|
|
214 |
return strftime($format, $dt->format('U'));
|
|
|
215 |
} else {
|
|
|
216 |
return $dt->format($format);
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
|
|
|
220 |
/**
|
|
|
221 |
* Get the [optionally formatted] temporal [end_date] column value.
|
|
|
222 |
*
|
|
|
223 |
*
|
|
|
224 |
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
|
|
225 |
* If format is NULL, then the raw DateTime object will be returned.
|
|
|
226 |
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
|
|
227 |
* @throws PropelException - if unable to parse/validate the date/time value.
|
|
|
228 |
*/
|
|
|
229 |
public function getEndDate($format = 'Y-m-d H:i:s')
|
|
|
230 |
{
|
|
|
231 |
if ($this->end_date === null) {
|
|
|
232 |
return null;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
try {
|
|
|
238 |
$dt = new DateTime($this->end_date);
|
|
|
239 |
} catch (Exception $x) {
|
|
|
240 |
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->end_date, true), $x);
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
if ($format === null) {
|
|
|
244 |
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
|
|
245 |
return $dt;
|
|
|
246 |
} elseif (strpos($format, '%') !== false) {
|
|
|
247 |
return strftime($format, $dt->format('U'));
|
|
|
248 |
} else {
|
|
|
249 |
return $dt->format($format);
|
|
|
250 |
}
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
/**
|
|
|
254 |
* Get the [book_id] column value.
|
|
|
255 |
*
|
|
|
256 |
* @return int
|
|
|
257 |
*/
|
|
|
258 |
public function getBookId()
|
|
|
259 |
{
|
|
|
260 |
return $this->book_id;
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
/**
|
|
|
264 |
* Set the value of [id] column.
|
|
|
265 |
*
|
|
|
266 |
* @param int $v new value
|
|
|
267 |
* @return Article The current object (for fluent API support)
|
|
|
268 |
*/
|
|
|
269 |
public function setId($v)
|
|
|
270 |
{
|
|
|
271 |
if ($v !== null) {
|
|
|
272 |
$v = (int) $v;
|
|
|
273 |
}
|
|
|
274 |
|
|
|
275 |
if ($this->id !== $v) {
|
|
|
276 |
$this->id = $v;
|
|
|
277 |
$this->modifiedColumns[] = ArticlePeer::ID;
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
return $this;
|
|
|
281 |
} // setId()
|
|
|
282 |
|
|
|
283 |
/**
|
|
|
284 |
* Set the value of [title] column.
|
|
|
285 |
*
|
|
|
286 |
* @param string $v new value
|
|
|
287 |
* @return Article The current object (for fluent API support)
|
|
|
288 |
*/
|
|
|
289 |
public function setTitle($v)
|
|
|
290 |
{
|
|
|
291 |
if ($v !== null) {
|
|
|
292 |
$v = (string) $v;
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
if ($this->title !== $v) {
|
|
|
296 |
$this->title = $v;
|
|
|
297 |
$this->modifiedColumns[] = ArticlePeer::TITLE;
|
|
|
298 |
}
|
|
|
299 |
|
|
|
300 |
return $this;
|
|
|
301 |
} // setTitle()
|
|
|
302 |
|
|
|
303 |
/**
|
|
|
304 |
* Set the value of [body] column.
|
|
|
305 |
*
|
|
|
306 |
* @param string $v new value
|
|
|
307 |
* @return Article The current object (for fluent API support)
|
|
|
308 |
*/
|
|
|
309 |
public function setBody($v)
|
|
|
310 |
{
|
|
|
311 |
if ($v !== null) {
|
|
|
312 |
$v = (string) $v;
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
if ($this->body !== $v) {
|
|
|
316 |
$this->body = $v;
|
|
|
317 |
$this->modifiedColumns[] = ArticlePeer::BODY;
|
|
|
318 |
}
|
|
|
319 |
|
|
|
320 |
return $this;
|
|
|
321 |
} // setBody()
|
|
|
322 |
|
|
|
323 |
/**
|
|
|
324 |
* Set the value of [online] column.
|
|
|
325 |
*
|
|
|
326 |
* @param boolean $v new value
|
|
|
327 |
* @return Article The current object (for fluent API support)
|
|
|
328 |
*/
|
|
|
329 |
public function setOnline($v)
|
|
|
330 |
{
|
|
|
331 |
if ($v !== null) {
|
|
|
332 |
$v = (boolean) $v;
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
if ($this->online !== $v) {
|
|
|
336 |
$this->online = $v;
|
|
|
337 |
$this->modifiedColumns[] = ArticlePeer::ONLINE;
|
|
|
338 |
}
|
|
|
339 |
|
|
|
340 |
return $this;
|
|
|
341 |
} // setOnline()
|
|
|
342 |
|
|
|
343 |
/**
|
|
|
344 |
* Set the value of [excerpt] column.
|
|
|
345 |
*
|
|
|
346 |
* @param string $v new value
|
|
|
347 |
* @return Article The current object (for fluent API support)
|
|
|
348 |
*/
|
|
|
349 |
public function setExcerpt($v)
|
|
|
350 |
{
|
|
|
351 |
if ($v !== null) {
|
|
|
352 |
$v = (string) $v;
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
if ($this->excerpt !== $v) {
|
|
|
356 |
$this->excerpt = $v;
|
|
|
357 |
$this->modifiedColumns[] = ArticlePeer::EXCERPT;
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
return $this;
|
|
|
361 |
} // setExcerpt()
|
|
|
362 |
|
|
|
363 |
/**
|
|
|
364 |
* Set the value of [category_id] column.
|
|
|
365 |
*
|
|
|
366 |
* @param int $v new value
|
|
|
367 |
* @return Article The current object (for fluent API support)
|
|
|
368 |
*/
|
|
|
369 |
public function setCategoryId($v)
|
|
|
370 |
{
|
|
|
371 |
if ($v !== null) {
|
|
|
372 |
$v = (int) $v;
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
if ($this->category_id !== $v) {
|
|
|
376 |
$this->category_id = $v;
|
|
|
377 |
$this->modifiedColumns[] = ArticlePeer::CATEGORY_ID;
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
if ($this->aCategory !== null && $this->aCategory->getId() !== $v) {
|
|
|
381 |
$this->aCategory = null;
|
|
|
382 |
}
|
|
|
383 |
|
|
|
384 |
return $this;
|
|
|
385 |
} // setCategoryId()
|
|
|
386 |
|
|
|
387 |
/**
|
|
|
388 |
* Sets the value of [created_at] column to a normalized version of the date/time value specified.
|
|
|
389 |
*
|
|
|
390 |
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
|
|
|
391 |
* be treated as NULL for temporal objects.
|
|
|
392 |
* @return Article The current object (for fluent API support)
|
|
|
393 |
*/
|
|
|
394 |
public function setCreatedAt($v)
|
|
|
395 |
{
|
|
|
396 |
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
|
|
|
397 |
// -- which is unexpected, to say the least.
|
|
|
398 |
if ($v === null || $v === '') {
|
|
|
399 |
$dt = null;
|
|
|
400 |
} elseif ($v instanceof DateTime) {
|
|
|
401 |
$dt = $v;
|
|
|
402 |
} else {
|
|
|
403 |
// some string/numeric value passed; we normalize that so that we can
|
|
|
404 |
// validate it.
|
|
|
405 |
try {
|
|
|
406 |
if (is_numeric($v)) { // if it's a unix timestamp
|
|
|
407 |
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
|
|
|
408 |
// We have to explicitly specify and then change the time zone because of a
|
|
|
409 |
// DateTime bug: http://bugs.php.net/bug.php?id=43003
|
|
|
410 |
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
|
|
411 |
} else {
|
|
|
412 |
$dt = new DateTime($v);
|
|
|
413 |
}
|
|
|
414 |
} catch (Exception $x) {
|
|
|
415 |
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
|
|
416 |
}
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
if ( $this->created_at !== null || $dt !== null ) {
|
|
|
420 |
// (nested ifs are a little easier to read in this case)
|
|
|
421 |
|
|
|
422 |
$currNorm = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
|
|
|
423 |
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
|
|
|
424 |
|
|
|
425 |
if ( ($currNorm !== $newNorm) // normalized values don't match
|
|
|
426 |
)
|
|
|
427 |
{
|
|
|
428 |
$this->created_at = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
|
|
|
429 |
$this->modifiedColumns[] = ArticlePeer::CREATED_AT;
|
|
|
430 |
}
|
|
|
431 |
} // if either are not null
|
|
|
432 |
|
|
|
433 |
return $this;
|
|
|
434 |
} // setCreatedAt()
|
|
|
435 |
|
|
|
436 |
/**
|
|
|
437 |
* Sets the value of [end_date] column to a normalized version of the date/time value specified.
|
|
|
438 |
*
|
|
|
439 |
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
|
|
|
440 |
* be treated as NULL for temporal objects.
|
|
|
441 |
* @return Article The current object (for fluent API support)
|
|
|
442 |
*/
|
|
|
443 |
public function setEndDate($v)
|
|
|
444 |
{
|
|
|
445 |
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
|
|
|
446 |
// -- which is unexpected, to say the least.
|
|
|
447 |
if ($v === null || $v === '') {
|
|
|
448 |
$dt = null;
|
|
|
449 |
} elseif ($v instanceof DateTime) {
|
|
|
450 |
$dt = $v;
|
|
|
451 |
} else {
|
|
|
452 |
// some string/numeric value passed; we normalize that so that we can
|
|
|
453 |
// validate it.
|
|
|
454 |
try {
|
|
|
455 |
if (is_numeric($v)) { // if it's a unix timestamp
|
|
|
456 |
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
|
|
|
457 |
// We have to explicitly specify and then change the time zone because of a
|
|
|
458 |
// DateTime bug: http://bugs.php.net/bug.php?id=43003
|
|
|
459 |
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
|
|
460 |
} else {
|
|
|
461 |
$dt = new DateTime($v);
|
|
|
462 |
}
|
|
|
463 |
} catch (Exception $x) {
|
|
|
464 |
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
if ( $this->end_date !== null || $dt !== null ) {
|
|
|
469 |
// (nested ifs are a little easier to read in this case)
|
|
|
470 |
|
|
|
471 |
$currNorm = ($this->end_date !== null && $tmpDt = new DateTime($this->end_date)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
|
|
|
472 |
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
|
|
|
473 |
|
|
|
474 |
if ( ($currNorm !== $newNorm) // normalized values don't match
|
|
|
475 |
)
|
|
|
476 |
{
|
|
|
477 |
$this->end_date = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
|
|
|
478 |
$this->modifiedColumns[] = ArticlePeer::END_DATE;
|
|
|
479 |
}
|
|
|
480 |
} // if either are not null
|
|
|
481 |
|
|
|
482 |
return $this;
|
|
|
483 |
} // setEndDate()
|
|
|
484 |
|
|
|
485 |
/**
|
|
|
486 |
* Set the value of [book_id] column.
|
|
|
487 |
*
|
|
|
488 |
* @param int $v new value
|
|
|
489 |
* @return Article The current object (for fluent API support)
|
|
|
490 |
*/
|
|
|
491 |
public function setBookId($v)
|
|
|
492 |
{
|
|
|
493 |
if ($v !== null) {
|
|
|
494 |
$v = (int) $v;
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
if ($this->book_id !== $v) {
|
|
|
498 |
$this->book_id = $v;
|
|
|
499 |
$this->modifiedColumns[] = ArticlePeer::BOOK_ID;
|
|
|
500 |
}
|
|
|
501 |
|
|
|
502 |
if ($this->aBook !== null && $this->aBook->getId() !== $v) {
|
|
|
503 |
$this->aBook = null;
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
return $this;
|
|
|
507 |
} // setBookId()
|
|
|
508 |
|
|
|
509 |
/**
|
|
|
510 |
* Indicates whether the columns in this object are only set to default values.
|
|
|
511 |
*
|
|
|
512 |
* This method can be used in conjunction with isModified() to indicate whether an object is both
|
|
|
513 |
* modified _and_ has some values set which are non-default.
|
|
|
514 |
*
|
|
|
515 |
* @return boolean Whether the columns in this object are only been set with default values.
|
|
|
516 |
*/
|
|
|
517 |
public function hasOnlyDefaultValues()
|
|
|
518 |
{
|
|
|
519 |
// otherwise, everything was equal, so return TRUE
|
|
|
520 |
return true;
|
|
|
521 |
} // hasOnlyDefaultValues()
|
|
|
522 |
|
|
|
523 |
/**
|
|
|
524 |
* Hydrates (populates) the object variables with values from the database resultset.
|
|
|
525 |
*
|
|
|
526 |
* An offset (0-based "start column") is specified so that objects can be hydrated
|
|
|
527 |
* with a subset of the columns in the resultset rows. This is needed, for example,
|
|
|
528 |
* for results of JOIN queries where the resultset row includes columns from two or
|
|
|
529 |
* more tables.
|
|
|
530 |
*
|
|
|
531 |
* @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
|
|
|
532 |
* @param int $startcol 0-based offset column which indicates which restultset column to start with.
|
|
|
533 |
* @param boolean $rehydrate Whether this object is being re-hydrated from the database.
|
|
|
534 |
* @return int next starting column
|
|
|
535 |
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
|
|
536 |
*/
|
|
|
537 |
public function hydrate($row, $startcol = 0, $rehydrate = false)
|
|
|
538 |
{
|
|
|
539 |
try {
|
|
|
540 |
|
|
|
541 |
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
|
|
542 |
$this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
|
|
|
543 |
$this->body = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
|
|
|
544 |
$this->online = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null;
|
|
|
545 |
$this->excerpt = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
|
|
|
546 |
$this->category_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
|
|
|
547 |
$this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
|
|
|
548 |
$this->end_date = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
|
|
|
549 |
$this->book_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
|
|
|
550 |
$this->resetModified();
|
|
|
551 |
|
|
|
552 |
$this->setNew(false);
|
|
|
553 |
|
|
|
554 |
if ($rehydrate) {
|
|
|
555 |
$this->ensureConsistency();
|
|
|
556 |
}
|
|
|
557 |
|
|
|
558 |
// FIXME - using NUM_COLUMNS may be clearer.
|
|
|
559 |
return $startcol + 9; // 9 = ArticlePeer::NUM_COLUMNS - ArticlePeer::NUM_LAZY_LOAD_COLUMNS).
|
|
|
560 |
|
|
|
561 |
} catch (Exception $e) {
|
|
|
562 |
throw new PropelException("Error populating Article object", $e);
|
|
|
563 |
}
|
|
|
564 |
}
|
|
|
565 |
|
|
|
566 |
/**
|
|
|
567 |
* Checks and repairs the internal consistency of the object.
|
|
|
568 |
*
|
|
|
569 |
* This method is executed after an already-instantiated object is re-hydrated
|
|
|
570 |
* from the database. It exists to check any foreign keys to make sure that
|
|
|
571 |
* the objects related to the current object are correct based on foreign key.
|
|
|
572 |
*
|
|
|
573 |
* You can override this method in the stub class, but you should always invoke
|
|
|
574 |
* the base method from the overridden method (i.e. parent::ensureConsistency()),
|
|
|
575 |
* in case your model changes.
|
|
|
576 |
*
|
|
|
577 |
* @throws PropelException
|
|
|
578 |
*/
|
|
|
579 |
public function ensureConsistency()
|
|
|
580 |
{
|
|
|
581 |
|
|
|
582 |
if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) {
|
|
|
583 |
$this->aCategory = null;
|
|
|
584 |
}
|
|
|
585 |
if ($this->aBook !== null && $this->book_id !== $this->aBook->getId()) {
|
|
|
586 |
$this->aBook = null;
|
|
|
587 |
}
|
|
|
588 |
} // ensureConsistency
|
|
|
589 |
|
|
|
590 |
/**
|
|
|
591 |
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
|
|
|
592 |
*
|
|
|
593 |
* This will only work if the object has been saved and has a valid primary key set.
|
|
|
594 |
*
|
|
|
595 |
* @param boolean $deep (optional) Whether to also de-associated any related objects.
|
|
|
596 |
* @param PropelPDO $con (optional) The PropelPDO connection to use.
|
|
|
597 |
* @return void
|
|
|
598 |
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
|
|
|
599 |
*/
|
|
|
600 |
public function reload($deep = false, PropelPDO $con = null)
|
|
|
601 |
{
|
|
|
602 |
if ($this->isDeleted()) {
|
|
|
603 |
throw new PropelException("Cannot reload a deleted object.");
|
|
|
604 |
}
|
|
|
605 |
|
|
|
606 |
if ($this->isNew()) {
|
|
|
607 |
throw new PropelException("Cannot reload an unsaved object.");
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
if ($con === null) {
|
|
|
611 |
$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
|
|
612 |
}
|
|
|
613 |
|
|
|
614 |
// We don't need to alter the object instance pool; we're just modifying this instance
|
|
|
615 |
// already in the pool.
|
|
|
616 |
|
|
|
617 |
$stmt = ArticlePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
|
|
|
618 |
$row = $stmt->fetch(PDO::FETCH_NUM);
|
|
|
619 |
$stmt->closeCursor();
|
|
|
620 |
if (!$row) {
|
|
|
621 |
throw new PropelException('Cannot find matching row in the database to reload object values.');
|
|
|
622 |
}
|
|
|
623 |
$this->hydrate($row, 0, true); // rehydrate
|
|
|
624 |
|
|
|
625 |
if ($deep) { // also de-associate any related objects?
|
|
|
626 |
|
|
|
627 |
$this->aCategory = null;
|
|
|
628 |
$this->aBook = null;
|
|
|
629 |
$this->collAuthorArticles = null;
|
|
|
630 |
$this->lastAuthorArticleCriteria = null;
|
|
|
631 |
|
|
|
632 |
$this->collAttachments = null;
|
|
|
633 |
$this->lastAttachmentCriteria = null;
|
|
|
634 |
|
|
|
635 |
} // if (deep)
|
|
|
636 |
}
|
|
|
637 |
|
|
|
638 |
/**
|
|
|
639 |
* Removes this object from datastore and sets delete attribute.
|
|
|
640 |
*
|
|
|
641 |
* @param PropelPDO $con
|
|
|
642 |
* @return void
|
|
|
643 |
* @throws PropelException
|
|
|
644 |
* @see BaseObject::setDeleted()
|
|
|
645 |
* @see BaseObject::isDeleted()
|
|
|
646 |
*/
|
|
|
647 |
public function delete(PropelPDO $con = null)
|
|
|
648 |
{
|
|
|
649 |
if ($this->isDeleted()) {
|
|
|
650 |
throw new PropelException("This object has already been deleted.");
|
|
|
651 |
}
|
|
|
652 |
|
|
|
653 |
if ($con === null) {
|
|
|
654 |
$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
|
|
655 |
}
|
|
|
656 |
|
|
|
657 |
$con->beginTransaction();
|
|
|
658 |
try {
|
|
|
659 |
$ret = $this->preDelete($con);
|
|
|
660 |
// symfony_behaviors behavior
|
|
|
661 |
foreach (sfMixer::getCallables('BaseArticle:delete:pre') as $callable)
|
|
|
662 |
{
|
|
|
663 |
if (call_user_func($callable, $this, $con))
|
|
|
664 |
{
|
|
|
665 |
$con->commit();
|
|
|
666 |
|
|
|
667 |
return;
|
|
|
668 |
}
|
|
|
669 |
}
|
|
|
670 |
|
|
|
671 |
if ($ret) {
|
|
|
672 |
ArticlePeer::doDelete($this, $con);
|
|
|
673 |
$this->postDelete($con);
|
|
|
674 |
// symfony_behaviors behavior
|
|
|
675 |
foreach (sfMixer::getCallables('BaseArticle:delete:post') as $callable)
|
|
|
676 |
{
|
|
|
677 |
call_user_func($callable, $this, $con);
|
|
|
678 |
}
|
|
|
679 |
|
|
|
680 |
$this->setDeleted(true);
|
|
|
681 |
$con->commit();
|
|
|
682 |
} else {
|
|
|
683 |
$con->commit();
|
|
|
684 |
}
|
|
|
685 |
} catch (PropelException $e) {
|
|
|
686 |
$con->rollBack();
|
|
|
687 |
throw $e;
|
|
|
688 |
}
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
/**
|
|
|
692 |
* Persists this object to the database.
|
|
|
693 |
*
|
|
|
694 |
* If the object is new, it inserts it; otherwise an update is performed.
|
|
|
695 |
* All modified related objects will also be persisted in the doSave()
|
|
|
696 |
* method. This method wraps all precipitate database operations in a
|
|
|
697 |
* single transaction.
|
|
|
698 |
*
|
|
|
699 |
* @param PropelPDO $con
|
|
|
700 |
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
|
|
701 |
* @throws PropelException
|
|
|
702 |
* @see doSave()
|
|
|
703 |
*/
|
|
|
704 |
public function save(PropelPDO $con = null)
|
|
|
705 |
{
|
|
|
706 |
if ($this->isDeleted()) {
|
|
|
707 |
throw new PropelException("You cannot save an object that has been deleted.");
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
if ($con === null) {
|
|
|
711 |
$con = Propel::getConnection(ArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
|
|
712 |
}
|
|
|
713 |
|
|
|
714 |
$con->beginTransaction();
|
|
|
715 |
$isInsert = $this->isNew();
|
|
|
716 |
try {
|
|
|
717 |
$ret = $this->preSave($con);
|
|
|
718 |
// symfony_behaviors behavior
|
|
|
719 |
foreach (sfMixer::getCallables('BaseArticle:save:pre') as $callable)
|
|
|
720 |
{
|
|
|
721 |
if (is_integer($affectedRows = call_user_func($callable, $this, $con)))
|
|
|
722 |
{
|
|
|
723 |
$con->commit();
|
|
|
724 |
|
|
|
725 |
return $affectedRows;
|
|
|
726 |
}
|
|
|
727 |
}
|
|
|
728 |
|
|
|
729 |
// symfony_timestampable behavior
|
|
|
730 |
|
|
|
731 |
if ($isInsert) {
|
|
|
732 |
$ret = $ret && $this->preInsert($con);
|
|
|
733 |
// symfony_timestampable behavior
|
|
|
734 |
if (!$this->isColumnModified(ArticlePeer::CREATED_AT))
|
|
|
735 |
{
|
|
|
736 |
$this->setCreatedAt(time());
|
|
|
737 |
}
|
|
|
738 |
|
|
|
739 |
} else {
|
|
|
740 |
$ret = $ret && $this->preUpdate($con);
|
|
|
741 |
}
|
|
|
742 |
if ($ret) {
|
|
|
743 |
$affectedRows = $this->doSave($con);
|
|
|
744 |
if ($isInsert) {
|
|
|
745 |
$this->postInsert($con);
|
|
|
746 |
} else {
|
|
|
747 |
$this->postUpdate($con);
|
|
|
748 |
}
|
|
|
749 |
$this->postSave($con);
|
|
|
750 |
// symfony_behaviors behavior
|
|
|
751 |
foreach (sfMixer::getCallables('BaseArticle:save:post') as $callable)
|
|
|
752 |
{
|
|
|
753 |
call_user_func($callable, $this, $con, $affectedRows);
|
|
|
754 |
}
|
|
|
755 |
|
|
|
756 |
ArticlePeer::addInstanceToPool($this);
|
|
|
757 |
} else {
|
|
|
758 |
$affectedRows = 0;
|
|
|
759 |
}
|
|
|
760 |
$con->commit();
|
|
|
761 |
return $affectedRows;
|
|
|
762 |
} catch (PropelException $e) {
|
|
|
763 |
$con->rollBack();
|
|
|
764 |
throw $e;
|
|
|
765 |
}
|
|
|
766 |
}
|
|
|
767 |
|
|
|
768 |
/**
|
|
|
769 |
* Performs the work of inserting or updating the row in the database.
|
|
|
770 |
*
|
|
|
771 |
* If the object is new, it inserts it; otherwise an update is performed.
|
|
|
772 |
* All related objects are also updated in this method.
|
|
|
773 |
*
|
|
|
774 |
* @param PropelPDO $con
|
|
|
775 |
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
|
|
776 |
* @throws PropelException
|
|
|
777 |
* @see save()
|
|
|
778 |
*/
|
|
|
779 |
protected function doSave(PropelPDO $con)
|
|
|
780 |
{
|
|
|
781 |
$affectedRows = 0; // initialize var to track total num of affected rows
|
|
|
782 |
if (!$this->alreadyInSave) {
|
|
|
783 |
$this->alreadyInSave = true;
|
|
|
784 |
|
|
|
785 |
// We call the save method on the following object(s) if they
|
|
|
786 |
// were passed to this object by their coresponding set
|
|
|
787 |
// method. This object relates to these object(s) by a
|
|
|
788 |
// foreign key reference.
|
|
|
789 |
|
|
|
790 |
if ($this->aCategory !== null) {
|
|
|
791 |
if ($this->aCategory->isModified() || $this->aCategory->isNew()) {
|
|
|
792 |
$affectedRows += $this->aCategory->save($con);
|
|
|
793 |
}
|
|
|
794 |
$this->setCategory($this->aCategory);
|
|
|
795 |
}
|
|
|
796 |
|
|
|
797 |
if ($this->aBook !== null) {
|
|
|
798 |
if ($this->aBook->isModified() || $this->aBook->isNew()) {
|
|
|
799 |
$affectedRows += $this->aBook->save($con);
|
|
|
800 |
}
|
|
|
801 |
$this->setBook($this->aBook);
|
|
|
802 |
}
|
|
|
803 |
|
|
|
804 |
if ($this->isNew() ) {
|
|
|
805 |
$this->modifiedColumns[] = ArticlePeer::ID;
|
|
|
806 |
}
|
|
|
807 |
|
|
|
808 |
// If this object has been modified, then save it to the database.
|
|
|
809 |
if ($this->isModified()) {
|
|
|
810 |
if ($this->isNew()) {
|
|
|
811 |
$pk = ArticlePeer::doInsert($this, $con);
|
|
|
812 |
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
|
|
813 |
// should always be true here (even though technically
|
|
|
814 |
// BasePeer::doInsert() can insert multiple rows).
|
|
|
815 |
|
|
|
816 |
$this->setId($pk); //[IMV] update autoincrement primary key
|
|
|
817 |
|
|
|
818 |
$this->setNew(false);
|
|
|
819 |
} else {
|
|
|
820 |
$affectedRows += ArticlePeer::doUpdate($this, $con);
|
|
|
821 |
}
|
|
|
822 |
|
|
|
823 |
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
|
|
824 |
}
|
|
|
825 |
|
|
|
826 |
if ($this->collAuthorArticles !== null) {
|
|
|
827 |
foreach ($this->collAuthorArticles as $referrerFK) {
|
|
|
828 |
if (!$referrerFK->isDeleted()) {
|
|
|
829 |
$affectedRows += $referrerFK->save($con);
|
|
|
830 |
}
|
|
|
831 |
}
|
|
|
832 |
}
|
|
|
833 |
|
|
|
834 |
if ($this->collAttachments !== null) {
|
|
|
835 |
foreach ($this->collAttachments as $referrerFK) {
|
|
|
836 |
if (!$referrerFK->isDeleted()) {
|
|
|
837 |
$affectedRows += $referrerFK->save($con);
|
|
|
838 |
}
|
|
|
839 |
}
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
$this->alreadyInSave = false;
|
|
|
843 |
|
|
|
844 |
}
|
|
|
845 |
return $affectedRows;
|
|
|
846 |
} // doSave()
|
|
|
847 |
|
|
|
848 |
/**
|
|
|
849 |
* Array of ValidationFailed objects.
|
|
|
850 |
* @var array ValidationFailed[]
|
|
|
851 |
*/
|
|
|
852 |
protected $validationFailures = array();
|
|
|
853 |
|
|
|
854 |
/**
|
|
|
855 |
* Gets any ValidationFailed objects that resulted from last call to validate().
|
|
|
856 |
*
|
|
|
857 |
*
|
|
|
858 |
* @return array ValidationFailed[]
|
|
|
859 |
* @see validate()
|
|
|
860 |
*/
|
|
|
861 |
public function getValidationFailures()
|
|
|
862 |
{
|
|
|
863 |
return $this->validationFailures;
|
|
|
864 |
}
|
|
|
865 |
|
|
|
866 |
/**
|
|
|
867 |
* Validates the objects modified field values and all objects related to this table.
|
|
|
868 |
*
|
|
|
869 |
* If $columns is either a column name or an array of column names
|
|
|
870 |
* only those columns are validated.
|
|
|
871 |
*
|
|
|
872 |
* @param mixed $columns Column name or an array of column names.
|
|
|
873 |
* @return boolean Whether all columns pass validation.
|
|
|
874 |
* @see doValidate()
|
|
|
875 |
* @see getValidationFailures()
|
|
|
876 |
*/
|
|
|
877 |
public function validate($columns = null)
|
|
|
878 |
{
|
|
|
879 |
$res = $this->doValidate($columns);
|
|
|
880 |
if ($res === true) {
|
|
|
881 |
$this->validationFailures = array();
|
|
|
882 |
return true;
|
|
|
883 |
} else {
|
|
|
884 |
$this->validationFailures = $res;
|
|
|
885 |
return false;
|
|
|
886 |
}
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
/**
|
|
|
890 |
* This function performs the validation work for complex object models.
|
|
|
891 |
*
|
|
|
892 |
* In addition to checking the current object, all related objects will
|
|
|
893 |
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
|
|
894 |
* an aggreagated array of ValidationFailed objects will be returned.
|
|
|
895 |
*
|
|
|
896 |
* @param array $columns Array of column names to validate.
|
|
|
897 |
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
|
|
898 |
*/
|
|
|
899 |
protected function doValidate($columns = null)
|
|
|
900 |
{
|
|
|
901 |
if (!$this->alreadyInValidation) {
|
|
|
902 |
$this->alreadyInValidation = true;
|
|
|
903 |
$retval = null;
|
|
|
904 |
|
|
|
905 |
$failureMap = array();
|
|
|
906 |
|
|
|
907 |
|
|
|
908 |
// We call the validate method on the following object(s) if they
|
|
|
909 |
// were passed to this object by their coresponding set
|
|
|
910 |
// method. This object relates to these object(s) by a
|
|
|
911 |
// foreign key reference.
|
|
|
912 |
|
|
|
913 |
if ($this->aCategory !== null) {
|
|
|
914 |
if (!$this->aCategory->validate($columns)) {
|
|
|
915 |
$failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures());
|
|
|
916 |
}
|
|
|
917 |
}
|
|
|
918 |
|
|
|
919 |
if ($this->aBook !== null) {
|
|
|
920 |
if (!$this->aBook->validate($columns)) {
|
|
|
921 |
$failureMap = array_merge($failureMap, $this->aBook->getValidationFailures());
|
|
|
922 |
}
|
|
|
923 |
}
|
|
|
924 |
|
|
|
925 |
|
|
|
926 |
if (($retval = ArticlePeer::doValidate($this, $columns)) !== true) {
|
|
|
927 |
$failureMap = array_merge($failureMap, $retval);
|
|
|
928 |
}
|
|
|
929 |
|
|
|
930 |
|
|
|
931 |
if ($this->collAuthorArticles !== null) {
|
|
|
932 |
foreach ($this->collAuthorArticles as $referrerFK) {
|
|
|
933 |
if (!$referrerFK->validate($columns)) {
|
|
|
934 |
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
|
|
|
935 |
}
|
|
|
936 |
}
|
|
|
937 |
}
|
|
|
938 |
|
|
|
939 |
if ($this->collAttachments !== null) {
|
|
|
940 |
foreach ($this->collAttachments as $referrerFK) {
|
|
|
941 |
if (!$referrerFK->validate($columns)) {
|
|
|
942 |
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
|
|
|
943 |
}
|
|
|
944 |
}
|
|
|
945 |
}
|
|
|
946 |
|
|
|
947 |
|
|
|
948 |
$this->alreadyInValidation = false;
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
return (!empty($failureMap) ? $failureMap : true);
|
|
|
952 |
}
|
|
|
953 |
|
|
|
954 |
/**
|
|
|
955 |
* Retrieves a field from the object by name passed in as a string.
|
|
|
956 |
*
|
|
|
957 |
* @param string $name name
|
|
|
958 |
* @param string $type The type of fieldname the $name is of:
|
|
|
959 |
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
|
|
960 |
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
|
|
961 |
* @return mixed Value of field.
|
|
|
962 |
*/
|
|
|
963 |
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
|
|
964 |
{
|
|
|
965 |
$pos = ArticlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
|
|
966 |
$field = $this->getByPosition($pos);
|
|
|
967 |
return $field;
|
|
|
968 |
}
|
|
|
969 |
|
|
|
970 |
/**
|
|
|
971 |
* Retrieves a field from the object by Position as specified in the xml schema.
|
|
|
972 |
* Zero-based.
|
|
|
973 |
*
|
|
|
974 |
* @param int $pos position in xml schema
|
|
|
975 |
* @return mixed Value of field at $pos
|
|
|
976 |
*/
|
|
|
977 |
public function getByPosition($pos)
|
|
|
978 |
{
|
|
|
979 |
switch($pos) {
|
|
|
980 |
case 0:
|
|
|
981 |
return $this->getId();
|
|
|
982 |
break;
|
|
|
983 |
case 1:
|
|
|
984 |
return $this->getTitle();
|
|
|
985 |
break;
|
|
|
986 |
case 2:
|
|
|
987 |
return $this->getBody();
|
|
|
988 |
break;
|
|
|
989 |
case 3:
|
|
|
990 |
return $this->getOnline();
|
|
|
991 |
break;
|
|
|
992 |
case 4:
|
|
|
993 |
return $this->getExcerpt();
|
|
|
994 |
break;
|
|
|
995 |
case 5:
|
|
|
996 |
return $this->getCategoryId();
|
|
|
997 |
break;
|
|
|
998 |
case 6:
|
|
|
999 |
return $this->getCreatedAt();
|
|
|
1000 |
break;
|
|
|
1001 |
case 7:
|
|
|
1002 |
return $this->getEndDate();
|
|
|
1003 |
break;
|
|
|
1004 |
case 8:
|
|
|
1005 |
return $this->getBookId();
|
|
|
1006 |
break;
|
|
|
1007 |
default:
|
|
|
1008 |
return null;
|
|
|
1009 |
break;
|
|
|
1010 |
} // switch()
|
|
|
1011 |
}
|
|
|
1012 |
|
|
|
1013 |
/**
|
|
|
1014 |
* Exports the object as an array.
|
|
|
1015 |
*
|
|
|
1016 |
* You can specify the key type of the array by passing one of the class
|
|
|
1017 |
* type constants.
|
|
|
1018 |
*
|
|
|
1019 |
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
|
|
1020 |
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
|
|
|
1021 |
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
|
|
|
1022 |
* @return an associative array containing the field names (as keys) and field values
|
|
|
1023 |
*/
|
|
|
1024 |
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
|
|
|
1025 |
{
|
|
|
1026 |
$keys = ArticlePeer::getFieldNames($keyType);
|
|
|
1027 |
$result = array(
|
|
|
1028 |
$keys[0] => $this->getId(),
|
|
|
1029 |
$keys[1] => $this->getTitle(),
|
|
|
1030 |
$keys[2] => $this->getBody(),
|
|
|
1031 |
$keys[3] => $this->getOnline(),
|
|
|
1032 |
$keys[4] => $this->getExcerpt(),
|
|
|
1033 |
$keys[5] => $this->getCategoryId(),
|
|
|
1034 |
$keys[6] => $this->getCreatedAt(),
|
|
|
1035 |
$keys[7] => $this->getEndDate(),
|
|
|
1036 |
$keys[8] => $this->getBookId(),
|
|
|
1037 |
);
|
|
|
1038 |
return $result;
|
|
|
1039 |
}
|
|
|
1040 |
|
|
|
1041 |
/**
|
|
|
1042 |
* Sets a field from the object by name passed in as a string.
|
|
|
1043 |
*
|
|
|
1044 |
* @param string $name peer name
|
|
|
1045 |
* @param mixed $value field value
|
|
|
1046 |
* @param string $type The type of fieldname the $name is of:
|
|
|
1047 |
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
|
|
1048 |
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
|
|
1049 |
* @return void
|
|
|
1050 |
*/
|
|
|
1051 |
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
|
|
1052 |
{
|
|
|
1053 |
$pos = ArticlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
|
|
1054 |
return $this->setByPosition($pos, $value);
|
|
|
1055 |
}
|
|
|
1056 |
|
|
|
1057 |
/**
|
|
|
1058 |
* Sets a field from the object by Position as specified in the xml schema.
|
|
|
1059 |
* Zero-based.
|
|
|
1060 |
*
|
|
|
1061 |
* @param int $pos position in xml schema
|
|
|
1062 |
* @param mixed $value field value
|
|
|
1063 |
* @return void
|
|
|
1064 |
*/
|
|
|
1065 |
public function setByPosition($pos, $value)
|
|
|
1066 |
{
|
|
|
1067 |
switch($pos) {
|
|
|
1068 |
case 0:
|
|
|
1069 |
$this->setId($value);
|
|
|
1070 |
break;
|
|
|
1071 |
case 1:
|
|
|
1072 |
$this->setTitle($value);
|
|
|
1073 |
break;
|
|
|
1074 |
case 2:
|
|
|
1075 |
$this->setBody($value);
|
|
|
1076 |
break;
|
|
|
1077 |
case 3:
|
|
|
1078 |
$this->setOnline($value);
|
|
|
1079 |
break;
|
|
|
1080 |
case 4:
|
|
|
1081 |
$this->setExcerpt($value);
|
|
|
1082 |
break;
|
|
|
1083 |
case 5:
|
|
|
1084 |
$this->setCategoryId($value);
|
|
|
1085 |
break;
|
|
|
1086 |
case 6:
|
|
|
1087 |
$this->setCreatedAt($value);
|
|
|
1088 |
break;
|
|
|
1089 |
case 7:
|
|
|
1090 |
$this->setEndDate($value);
|
|
|
1091 |
break;
|
|
|
1092 |
case 8:
|
|
|
1093 |
$this->setBookId($value);
|
|
|
1094 |
break;
|
|
|
1095 |
} // switch()
|
|
|
1096 |
}
|
|
|
1097 |
|
|
|
1098 |
/**
|
|
|
1099 |
* Populates the object using an array.
|
|
|
1100 |
*
|
|
|
1101 |
* This is particularly useful when populating an object from one of the
|
|
|
1102 |
* request arrays (e.g. $_POST). This method goes through the column
|
|
|
1103 |
* names, checking to see whether a matching key exists in populated
|
|
|
1104 |
* array. If so the setByName() method is called for that column.
|
|
|
1105 |
*
|
|
|
1106 |
* You can specify the key type of the array by additionally passing one
|
|
|
1107 |
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
|
|
|
1108 |
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
|
|
|
1109 |
* The default key type is the column's phpname (e.g. 'AuthorId')
|
|
|
1110 |
*
|
|
|
1111 |
* @param array $arr An array to populate the object from.
|
|
|
1112 |
* @param string $keyType The type of keys the array uses.
|
|
|
1113 |
* @return void
|
|
|
1114 |
*/
|
|
|
1115 |
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
|
|
1116 |
{
|
|
|
1117 |
$keys = ArticlePeer::getFieldNames($keyType);
|
|
|
1118 |
|
|
|
1119 |
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
|
|
|
1120 |
if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]);
|
|
|
1121 |
if (array_key_exists($keys[2], $arr)) $this->setBody($arr[$keys[2]]);
|
|
|
1122 |
if (array_key_exists($keys[3], $arr)) $this->setOnline($arr[$keys[3]]);
|
|
|
1123 |
if (array_key_exists($keys[4], $arr)) $this->setExcerpt($arr[$keys[4]]);
|
|
|
1124 |
if (array_key_exists($keys[5], $arr)) $this->setCategoryId($arr[$keys[5]]);
|
|
|
1125 |
if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]);
|
|
|
1126 |
if (array_key_exists($keys[7], $arr)) $this->setEndDate($arr[$keys[7]]);
|
|
|
1127 |
if (array_key_exists($keys[8], $arr)) $this->setBookId($arr[$keys[8]]);
|
|
|
1128 |
}
|
|
|
1129 |
|
|
|
1130 |
/**
|
|
|
1131 |
* Build a Criteria object containing the values of all modified columns in this object.
|
|
|
1132 |
*
|
|
|
1133 |
* @return Criteria The Criteria object containing all modified values.
|
|
|
1134 |
*/
|
|
|
1135 |
public function buildCriteria()
|
|
|
1136 |
{
|
|
|
1137 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1138 |
|
|
|
1139 |
if ($this->isColumnModified(ArticlePeer::ID)) $criteria->add(ArticlePeer::ID, $this->id);
|
|
|
1140 |
if ($this->isColumnModified(ArticlePeer::TITLE)) $criteria->add(ArticlePeer::TITLE, $this->title);
|
|
|
1141 |
if ($this->isColumnModified(ArticlePeer::BODY)) $criteria->add(ArticlePeer::BODY, $this->body);
|
|
|
1142 |
if ($this->isColumnModified(ArticlePeer::ONLINE)) $criteria->add(ArticlePeer::ONLINE, $this->online);
|
|
|
1143 |
if ($this->isColumnModified(ArticlePeer::EXCERPT)) $criteria->add(ArticlePeer::EXCERPT, $this->excerpt);
|
|
|
1144 |
if ($this->isColumnModified(ArticlePeer::CATEGORY_ID)) $criteria->add(ArticlePeer::CATEGORY_ID, $this->category_id);
|
|
|
1145 |
if ($this->isColumnModified(ArticlePeer::CREATED_AT)) $criteria->add(ArticlePeer::CREATED_AT, $this->created_at);
|
|
|
1146 |
if ($this->isColumnModified(ArticlePeer::END_DATE)) $criteria->add(ArticlePeer::END_DATE, $this->end_date);
|
|
|
1147 |
if ($this->isColumnModified(ArticlePeer::BOOK_ID)) $criteria->add(ArticlePeer::BOOK_ID, $this->book_id);
|
|
|
1148 |
|
|
|
1149 |
return $criteria;
|
|
|
1150 |
}
|
|
|
1151 |
|
|
|
1152 |
/**
|
|
|
1153 |
* Builds a Criteria object containing the primary key for this object.
|
|
|
1154 |
*
|
|
|
1155 |
* Unlike buildCriteria() this method includes the primary key values regardless
|
|
|
1156 |
* of whether or not they have been modified.
|
|
|
1157 |
*
|
|
|
1158 |
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
|
|
1159 |
*/
|
|
|
1160 |
public function buildPkeyCriteria()
|
|
|
1161 |
{
|
|
|
1162 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1163 |
|
|
|
1164 |
$criteria->add(ArticlePeer::ID, $this->id);
|
|
|
1165 |
|
|
|
1166 |
return $criteria;
|
|
|
1167 |
}
|
|
|
1168 |
|
|
|
1169 |
/**
|
|
|
1170 |
* Returns the primary key for this object (row).
|
|
|
1171 |
* @return int
|
|
|
1172 |
*/
|
|
|
1173 |
public function getPrimaryKey()
|
|
|
1174 |
{
|
|
|
1175 |
return $this->getId();
|
|
|
1176 |
}
|
|
|
1177 |
|
|
|
1178 |
/**
|
|
|
1179 |
* Generic method to set the primary key (id column).
|
|
|
1180 |
*
|
|
|
1181 |
* @param int $key Primary key.
|
|
|
1182 |
* @return void
|
|
|
1183 |
*/
|
|
|
1184 |
public function setPrimaryKey($key)
|
|
|
1185 |
{
|
|
|
1186 |
$this->setId($key);
|
|
|
1187 |
}
|
|
|
1188 |
|
|
|
1189 |
/**
|
|
|
1190 |
* Sets contents of passed object to values from current object.
|
|
|
1191 |
*
|
|
|
1192 |
* If desired, this method can also make copies of all associated (fkey referrers)
|
|
|
1193 |
* objects.
|
|
|
1194 |
*
|
|
|
1195 |
* @param object $copyObj An object of Article (or compatible) type.
|
|
|
1196 |
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
|
|
1197 |
* @throws PropelException
|
|
|
1198 |
*/
|
|
|
1199 |
public function copyInto($copyObj, $deepCopy = false)
|
|
|
1200 |
{
|
|
|
1201 |
|
|
|
1202 |
$copyObj->setTitle($this->title);
|
|
|
1203 |
|
|
|
1204 |
$copyObj->setBody($this->body);
|
|
|
1205 |
|
|
|
1206 |
$copyObj->setOnline($this->online);
|
|
|
1207 |
|
|
|
1208 |
$copyObj->setExcerpt($this->excerpt);
|
|
|
1209 |
|
|
|
1210 |
$copyObj->setCategoryId($this->category_id);
|
|
|
1211 |
|
|
|
1212 |
$copyObj->setCreatedAt($this->created_at);
|
|
|
1213 |
|
|
|
1214 |
$copyObj->setEndDate($this->end_date);
|
|
|
1215 |
|
|
|
1216 |
$copyObj->setBookId($this->book_id);
|
|
|
1217 |
|
|
|
1218 |
|
|
|
1219 |
if ($deepCopy) {
|
|
|
1220 |
// important: temporarily setNew(false) because this affects the behavior of
|
|
|
1221 |
// the getter/setter methods for fkey referrer objects.
|
|
|
1222 |
$copyObj->setNew(false);
|
|
|
1223 |
|
|
|
1224 |
foreach ($this->getAuthorArticles() as $relObj) {
|
|
|
1225 |
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
|
|
1226 |
$copyObj->addAuthorArticle($relObj->copy($deepCopy));
|
|
|
1227 |
}
|
|
|
1228 |
}
|
|
|
1229 |
|
|
|
1230 |
foreach ($this->getAttachments() as $relObj) {
|
|
|
1231 |
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
|
|
1232 |
$copyObj->addAttachment($relObj->copy($deepCopy));
|
|
|
1233 |
}
|
|
|
1234 |
}
|
|
|
1235 |
|
|
|
1236 |
} // if ($deepCopy)
|
|
|
1237 |
|
|
|
1238 |
|
|
|
1239 |
$copyObj->setNew(true);
|
|
|
1240 |
|
|
|
1241 |
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
|
|
1242 |
|
|
|
1243 |
}
|
|
|
1244 |
|
|
|
1245 |
/**
|
|
|
1246 |
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
|
|
1247 |
* It creates a new object filling in the simple attributes, but skipping any primary
|
|
|
1248 |
* keys that are defined for the table.
|
|
|
1249 |
*
|
|
|
1250 |
* If desired, this method can also make copies of all associated (fkey referrers)
|
|
|
1251 |
* objects.
|
|
|
1252 |
*
|
|
|
1253 |
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
|
|
1254 |
* @return Article Clone of current object.
|
|
|
1255 |
* @throws PropelException
|
|
|
1256 |
*/
|
|
|
1257 |
public function copy($deepCopy = false)
|
|
|
1258 |
{
|
|
|
1259 |
// we use get_class(), because this might be a subclass
|
|
|
1260 |
$clazz = get_class($this);
|
|
|
1261 |
$copyObj = new $clazz();
|
|
|
1262 |
$this->copyInto($copyObj, $deepCopy);
|
|
|
1263 |
return $copyObj;
|
|
|
1264 |
}
|
|
|
1265 |
|
|
|
1266 |
/**
|
|
|
1267 |
* Returns a peer instance associated with this om.
|
|
|
1268 |
*
|
|
|
1269 |
* Since Peer classes are not to have any instance attributes, this method returns the
|
|
|
1270 |
* same instance for all member of this class. The method could therefore
|
|
|
1271 |
* be static, but this would prevent one from overriding the behavior.
|
|
|
1272 |
*
|
|
|
1273 |
* @return ArticlePeer
|
|
|
1274 |
*/
|
|
|
1275 |
public function getPeer()
|
|
|
1276 |
{
|
|
|
1277 |
if (self::$peer === null) {
|
|
|
1278 |
self::$peer = new ArticlePeer();
|
|
|
1279 |
}
|
|
|
1280 |
return self::$peer;
|
|
|
1281 |
}
|
|
|
1282 |
|
|
|
1283 |
/**
|
|
|
1284 |
* Declares an association between this object and a Category object.
|
|
|
1285 |
*
|
|
|
1286 |
* @param Category $v
|
|
|
1287 |
* @return Article The current object (for fluent API support)
|
|
|
1288 |
* @throws PropelException
|
|
|
1289 |
*/
|
|
|
1290 |
public function setCategory(Category $v = null)
|
|
|
1291 |
{
|
|
|
1292 |
if ($v === null) {
|
|
|
1293 |
$this->setCategoryId(NULL);
|
|
|
1294 |
} else {
|
|
|
1295 |
$this->setCategoryId($v->getId());
|
|
|
1296 |
}
|
|
|
1297 |
|
|
|
1298 |
$this->aCategory = $v;
|
|
|
1299 |
|
|
|
1300 |
// Add binding for other direction of this n:n relationship.
|
|
|
1301 |
// If this object has already been added to the Category object, it will not be re-added.
|
|
|
1302 |
if ($v !== null) {
|
|
|
1303 |
$v->addArticle($this);
|
|
|
1304 |
}
|
|
|
1305 |
|
|
|
1306 |
return $this;
|
|
|
1307 |
}
|
|
|
1308 |
|
|
|
1309 |
|
|
|
1310 |
/**
|
|
|
1311 |
* Get the associated Category object
|
|
|
1312 |
*
|
|
|
1313 |
* @param PropelPDO Optional Connection object.
|
|
|
1314 |
* @return Category The associated Category object.
|
|
|
1315 |
* @throws PropelException
|
|
|
1316 |
*/
|
|
|
1317 |
public function getCategory(PropelPDO $con = null)
|
|
|
1318 |
{
|
|
|
1319 |
if ($this->aCategory === null && ($this->category_id !== null)) {
|
|
|
1320 |
$this->aCategory = CategoryPeer::retrieveByPk($this->category_id);
|
|
|
1321 |
/* The following can be used additionally to
|
|
|
1322 |
guarantee the related object contains a reference
|
|
|
1323 |
to this object. This level of coupling may, however, be
|
|
|
1324 |
undesirable since it could result in an only partially populated collection
|
|
|
1325 |
in the referenced object.
|
|
|
1326 |
$this->aCategory->addArticles($this);
|
|
|
1327 |
*/
|
|
|
1328 |
}
|
|
|
1329 |
return $this->aCategory;
|
|
|
1330 |
}
|
|
|
1331 |
|
|
|
1332 |
/**
|
|
|
1333 |
* Declares an association between this object and a Book object.
|
|
|
1334 |
*
|
|
|
1335 |
* @param Book $v
|
|
|
1336 |
* @return Article The current object (for fluent API support)
|
|
|
1337 |
* @throws PropelException
|
|
|
1338 |
*/
|
|
|
1339 |
public function setBook(Book $v = null)
|
|
|
1340 |
{
|
|
|
1341 |
if ($v === null) {
|
|
|
1342 |
$this->setBookId(NULL);
|
|
|
1343 |
} else {
|
|
|
1344 |
$this->setBookId($v->getId());
|
|
|
1345 |
}
|
|
|
1346 |
|
|
|
1347 |
$this->aBook = $v;
|
|
|
1348 |
|
|
|
1349 |
// Add binding for other direction of this n:n relationship.
|
|
|
1350 |
// If this object has already been added to the Book object, it will not be re-added.
|
|
|
1351 |
if ($v !== null) {
|
|
|
1352 |
$v->addArticle($this);
|
|
|
1353 |
}
|
|
|
1354 |
|
|
|
1355 |
return $this;
|
|
|
1356 |
}
|
|
|
1357 |
|
|
|
1358 |
|
|
|
1359 |
/**
|
|
|
1360 |
* Get the associated Book object
|
|
|
1361 |
*
|
|
|
1362 |
* @param PropelPDO Optional Connection object.
|
|
|
1363 |
* @return Book The associated Book object.
|
|
|
1364 |
* @throws PropelException
|
|
|
1365 |
*/
|
|
|
1366 |
public function getBook(PropelPDO $con = null)
|
|
|
1367 |
{
|
|
|
1368 |
if ($this->aBook === null && ($this->book_id !== null)) {
|
|
|
1369 |
$this->aBook = BookPeer::retrieveByPk($this->book_id);
|
|
|
1370 |
/* The following can be used additionally to
|
|
|
1371 |
guarantee the related object contains a reference
|
|
|
1372 |
to this object. This level of coupling may, however, be
|
|
|
1373 |
undesirable since it could result in an only partially populated collection
|
|
|
1374 |
in the referenced object.
|
|
|
1375 |
$this->aBook->addArticles($this);
|
|
|
1376 |
*/
|
|
|
1377 |
}
|
|
|
1378 |
return $this->aBook;
|
|
|
1379 |
}
|
|
|
1380 |
|
|
|
1381 |
/**
|
|
|
1382 |
* Clears out the collAuthorArticles collection (array).
|
|
|
1383 |
*
|
|
|
1384 |
* This does not modify the database; however, it will remove any associated objects, causing
|
|
|
1385 |
* them to be refetched by subsequent calls to accessor method.
|
|
|
1386 |
*
|
|
|
1387 |
* @return void
|
|
|
1388 |
* @see addAuthorArticles()
|
|
|
1389 |
*/
|
|
|
1390 |
public function clearAuthorArticles()
|
|
|
1391 |
{
|
|
|
1392 |
$this->collAuthorArticles = null; // important to set this to NULL since that means it is uninitialized
|
|
|
1393 |
}
|
|
|
1394 |
|
|
|
1395 |
/**
|
|
|
1396 |
* Initializes the collAuthorArticles collection (array).
|
|
|
1397 |
*
|
|
|
1398 |
* By default this just sets the collAuthorArticles collection to an empty array (like clearcollAuthorArticles());
|
|
|
1399 |
* however, you may wish to override this method in your stub class to provide setting appropriate
|
|
|
1400 |
* to your application -- for example, setting the initial array to the values stored in database.
|
|
|
1401 |
*
|
|
|
1402 |
* @return void
|
|
|
1403 |
*/
|
|
|
1404 |
public function initAuthorArticles()
|
|
|
1405 |
{
|
|
|
1406 |
$this->collAuthorArticles = array();
|
|
|
1407 |
}
|
|
|
1408 |
|
|
|
1409 |
/**
|
|
|
1410 |
* Gets an array of AuthorArticle objects which contain a foreign key that references this object.
|
|
|
1411 |
*
|
|
|
1412 |
* If this collection has already been initialized with an identical Criteria, it returns the collection.
|
|
|
1413 |
* Otherwise if this Article has previously been saved, it will retrieve
|
|
|
1414 |
* related AuthorArticles from storage. If this Article is new, it will return
|
|
|
1415 |
* an empty collection or the current collection, the criteria is ignored on a new object.
|
|
|
1416 |
*
|
|
|
1417 |
* @param PropelPDO $con
|
|
|
1418 |
* @param Criteria $criteria
|
|
|
1419 |
* @return array AuthorArticle[]
|
|
|
1420 |
* @throws PropelException
|
|
|
1421 |
*/
|
|
|
1422 |
public function getAuthorArticles($criteria = null, PropelPDO $con = null)
|
|
|
1423 |
{
|
|
|
1424 |
if ($criteria === null) {
|
|
|
1425 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1426 |
}
|
|
|
1427 |
elseif ($criteria instanceof Criteria)
|
|
|
1428 |
{
|
|
|
1429 |
$criteria = clone $criteria;
|
|
|
1430 |
}
|
|
|
1431 |
|
|
|
1432 |
if ($this->collAuthorArticles === null) {
|
|
|
1433 |
if ($this->isNew()) {
|
|
|
1434 |
$this->collAuthorArticles = array();
|
|
|
1435 |
} else {
|
|
|
1436 |
|
|
|
1437 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1438 |
|
|
|
1439 |
AuthorArticlePeer::addSelectColumns($criteria);
|
|
|
1440 |
$this->collAuthorArticles = AuthorArticlePeer::doSelect($criteria, $con);
|
|
|
1441 |
}
|
|
|
1442 |
} else {
|
|
|
1443 |
// criteria has no effect for a new object
|
|
|
1444 |
if (!$this->isNew()) {
|
|
|
1445 |
// the following code is to determine if a new query is
|
|
|
1446 |
// called for. If the criteria is the same as the last
|
|
|
1447 |
// one, just return the collection.
|
|
|
1448 |
|
|
|
1449 |
|
|
|
1450 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1451 |
|
|
|
1452 |
AuthorArticlePeer::addSelectColumns($criteria);
|
|
|
1453 |
if (!isset($this->lastAuthorArticleCriteria) || !$this->lastAuthorArticleCriteria->equals($criteria)) {
|
|
|
1454 |
$this->collAuthorArticles = AuthorArticlePeer::doSelect($criteria, $con);
|
|
|
1455 |
}
|
|
|
1456 |
}
|
|
|
1457 |
}
|
|
|
1458 |
$this->lastAuthorArticleCriteria = $criteria;
|
|
|
1459 |
return $this->collAuthorArticles;
|
|
|
1460 |
}
|
|
|
1461 |
|
|
|
1462 |
/**
|
|
|
1463 |
* Returns the number of related AuthorArticle objects.
|
|
|
1464 |
*
|
|
|
1465 |
* @param Criteria $criteria
|
|
|
1466 |
* @param boolean $distinct
|
|
|
1467 |
* @param PropelPDO $con
|
|
|
1468 |
* @return int Count of related AuthorArticle objects.
|
|
|
1469 |
* @throws PropelException
|
|
|
1470 |
*/
|
|
|
1471 |
public function countAuthorArticles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
|
|
|
1472 |
{
|
|
|
1473 |
if ($criteria === null) {
|
|
|
1474 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1475 |
} else {
|
|
|
1476 |
$criteria = clone $criteria;
|
|
|
1477 |
}
|
|
|
1478 |
|
|
|
1479 |
if ($distinct) {
|
|
|
1480 |
$criteria->setDistinct();
|
|
|
1481 |
}
|
|
|
1482 |
|
|
|
1483 |
$count = null;
|
|
|
1484 |
|
|
|
1485 |
if ($this->collAuthorArticles === null) {
|
|
|
1486 |
if ($this->isNew()) {
|
|
|
1487 |
$count = 0;
|
|
|
1488 |
} else {
|
|
|
1489 |
|
|
|
1490 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1491 |
|
|
|
1492 |
$count = AuthorArticlePeer::doCount($criteria, false, $con);
|
|
|
1493 |
}
|
|
|
1494 |
} else {
|
|
|
1495 |
// criteria has no effect for a new object
|
|
|
1496 |
if (!$this->isNew()) {
|
|
|
1497 |
// the following code is to determine if a new query is
|
|
|
1498 |
// called for. If the criteria is the same as the last
|
|
|
1499 |
// one, just return count of the collection.
|
|
|
1500 |
|
|
|
1501 |
|
|
|
1502 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1503 |
|
|
|
1504 |
if (!isset($this->lastAuthorArticleCriteria) || !$this->lastAuthorArticleCriteria->equals($criteria)) {
|
|
|
1505 |
$count = AuthorArticlePeer::doCount($criteria, false, $con);
|
|
|
1506 |
} else {
|
|
|
1507 |
$count = count($this->collAuthorArticles);
|
|
|
1508 |
}
|
|
|
1509 |
} else {
|
|
|
1510 |
$count = count($this->collAuthorArticles);
|
|
|
1511 |
}
|
|
|
1512 |
}
|
|
|
1513 |
return $count;
|
|
|
1514 |
}
|
|
|
1515 |
|
|
|
1516 |
/**
|
|
|
1517 |
* Method called to associate a AuthorArticle object to this object
|
|
|
1518 |
* through the AuthorArticle foreign key attribute.
|
|
|
1519 |
*
|
|
|
1520 |
* @param AuthorArticle $l AuthorArticle
|
|
|
1521 |
* @return void
|
|
|
1522 |
* @throws PropelException
|
|
|
1523 |
*/
|
|
|
1524 |
public function addAuthorArticle(AuthorArticle $l)
|
|
|
1525 |
{
|
|
|
1526 |
if ($this->collAuthorArticles === null) {
|
|
|
1527 |
$this->initAuthorArticles();
|
|
|
1528 |
}
|
|
|
1529 |
if (!in_array($l, $this->collAuthorArticles, true)) { // only add it if the **same** object is not already associated
|
|
|
1530 |
array_push($this->collAuthorArticles, $l);
|
|
|
1531 |
$l->setArticle($this);
|
|
|
1532 |
}
|
|
|
1533 |
}
|
|
|
1534 |
|
|
|
1535 |
|
|
|
1536 |
/**
|
|
|
1537 |
* If this collection has already been initialized with
|
|
|
1538 |
* an identical criteria, it returns the collection.
|
|
|
1539 |
* Otherwise if this Article is new, it will return
|
|
|
1540 |
* an empty collection; or if this Article has previously
|
|
|
1541 |
* been saved, it will retrieve related AuthorArticles from storage.
|
|
|
1542 |
*
|
|
|
1543 |
* This method is protected by default in order to keep the public
|
|
|
1544 |
* api reasonable. You can provide public methods for those you
|
|
|
1545 |
* actually need in Article.
|
|
|
1546 |
*/
|
|
|
1547 |
public function getAuthorArticlesJoinAuthor($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
|
|
|
1548 |
{
|
|
|
1549 |
if ($criteria === null) {
|
|
|
1550 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1551 |
}
|
|
|
1552 |
elseif ($criteria instanceof Criteria)
|
|
|
1553 |
{
|
|
|
1554 |
$criteria = clone $criteria;
|
|
|
1555 |
}
|
|
|
1556 |
|
|
|
1557 |
if ($this->collAuthorArticles === null) {
|
|
|
1558 |
if ($this->isNew()) {
|
|
|
1559 |
$this->collAuthorArticles = array();
|
|
|
1560 |
} else {
|
|
|
1561 |
|
|
|
1562 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1563 |
|
|
|
1564 |
$this->collAuthorArticles = AuthorArticlePeer::doSelectJoinAuthor($criteria, $con, $join_behavior);
|
|
|
1565 |
}
|
|
|
1566 |
} else {
|
|
|
1567 |
// the following code is to determine if a new query is
|
|
|
1568 |
// called for. If the criteria is the same as the last
|
|
|
1569 |
// one, just return the collection.
|
|
|
1570 |
|
|
|
1571 |
$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->id);
|
|
|
1572 |
|
|
|
1573 |
if (!isset($this->lastAuthorArticleCriteria) || !$this->lastAuthorArticleCriteria->equals($criteria)) {
|
|
|
1574 |
$this->collAuthorArticles = AuthorArticlePeer::doSelectJoinAuthor($criteria, $con, $join_behavior);
|
|
|
1575 |
}
|
|
|
1576 |
}
|
|
|
1577 |
$this->lastAuthorArticleCriteria = $criteria;
|
|
|
1578 |
|
|
|
1579 |
return $this->collAuthorArticles;
|
|
|
1580 |
}
|
|
|
1581 |
|
|
|
1582 |
/**
|
|
|
1583 |
* Clears out the collAttachments collection (array).
|
|
|
1584 |
*
|
|
|
1585 |
* This does not modify the database; however, it will remove any associated objects, causing
|
|
|
1586 |
* them to be refetched by subsequent calls to accessor method.
|
|
|
1587 |
*
|
|
|
1588 |
* @return void
|
|
|
1589 |
* @see addAttachments()
|
|
|
1590 |
*/
|
|
|
1591 |
public function clearAttachments()
|
|
|
1592 |
{
|
|
|
1593 |
$this->collAttachments = null; // important to set this to NULL since that means it is uninitialized
|
|
|
1594 |
}
|
|
|
1595 |
|
|
|
1596 |
/**
|
|
|
1597 |
* Initializes the collAttachments collection (array).
|
|
|
1598 |
*
|
|
|
1599 |
* By default this just sets the collAttachments collection to an empty array (like clearcollAttachments());
|
|
|
1600 |
* however, you may wish to override this method in your stub class to provide setting appropriate
|
|
|
1601 |
* to your application -- for example, setting the initial array to the values stored in database.
|
|
|
1602 |
*
|
|
|
1603 |
* @return void
|
|
|
1604 |
*/
|
|
|
1605 |
public function initAttachments()
|
|
|
1606 |
{
|
|
|
1607 |
$this->collAttachments = array();
|
|
|
1608 |
}
|
|
|
1609 |
|
|
|
1610 |
/**
|
|
|
1611 |
* Gets an array of Attachment objects which contain a foreign key that references this object.
|
|
|
1612 |
*
|
|
|
1613 |
* If this collection has already been initialized with an identical Criteria, it returns the collection.
|
|
|
1614 |
* Otherwise if this Article has previously been saved, it will retrieve
|
|
|
1615 |
* related Attachments from storage. If this Article is new, it will return
|
|
|
1616 |
* an empty collection or the current collection, the criteria is ignored on a new object.
|
|
|
1617 |
*
|
|
|
1618 |
* @param PropelPDO $con
|
|
|
1619 |
* @param Criteria $criteria
|
|
|
1620 |
* @return array Attachment[]
|
|
|
1621 |
* @throws PropelException
|
|
|
1622 |
*/
|
|
|
1623 |
public function getAttachments($criteria = null, PropelPDO $con = null)
|
|
|
1624 |
{
|
|
|
1625 |
if ($criteria === null) {
|
|
|
1626 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1627 |
}
|
|
|
1628 |
elseif ($criteria instanceof Criteria)
|
|
|
1629 |
{
|
|
|
1630 |
$criteria = clone $criteria;
|
|
|
1631 |
}
|
|
|
1632 |
|
|
|
1633 |
if ($this->collAttachments === null) {
|
|
|
1634 |
if ($this->isNew()) {
|
|
|
1635 |
$this->collAttachments = array();
|
|
|
1636 |
} else {
|
|
|
1637 |
|
|
|
1638 |
$criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
|
|
|
1639 |
|
|
|
1640 |
AttachmentPeer::addSelectColumns($criteria);
|
|
|
1641 |
$this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
|
|
|
1642 |
}
|
|
|
1643 |
} else {
|
|
|
1644 |
// criteria has no effect for a new object
|
|
|
1645 |
if (!$this->isNew()) {
|
|
|
1646 |
// the following code is to determine if a new query is
|
|
|
1647 |
// called for. If the criteria is the same as the last
|
|
|
1648 |
// one, just return the collection.
|
|
|
1649 |
|
|
|
1650 |
|
|
|
1651 |
$criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
|
|
|
1652 |
|
|
|
1653 |
AttachmentPeer::addSelectColumns($criteria);
|
|
|
1654 |
if (!isset($this->lastAttachmentCriteria) || !$this->lastAttachmentCriteria->equals($criteria)) {
|
|
|
1655 |
$this->collAttachments = AttachmentPeer::doSelect($criteria, $con);
|
|
|
1656 |
}
|
|
|
1657 |
}
|
|
|
1658 |
}
|
|
|
1659 |
$this->lastAttachmentCriteria = $criteria;
|
|
|
1660 |
return $this->collAttachments;
|
|
|
1661 |
}
|
|
|
1662 |
|
|
|
1663 |
/**
|
|
|
1664 |
* Returns the number of related Attachment objects.
|
|
|
1665 |
*
|
|
|
1666 |
* @param Criteria $criteria
|
|
|
1667 |
* @param boolean $distinct
|
|
|
1668 |
* @param PropelPDO $con
|
|
|
1669 |
* @return int Count of related Attachment objects.
|
|
|
1670 |
* @throws PropelException
|
|
|
1671 |
*/
|
|
|
1672 |
public function countAttachments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
|
|
|
1673 |
{
|
|
|
1674 |
if ($criteria === null) {
|
|
|
1675 |
$criteria = new Criteria(ArticlePeer::DATABASE_NAME);
|
|
|
1676 |
} else {
|
|
|
1677 |
$criteria = clone $criteria;
|
|
|
1678 |
}
|
|
|
1679 |
|
|
|
1680 |
if ($distinct) {
|
|
|
1681 |
$criteria->setDistinct();
|
|
|
1682 |
}
|
|
|
1683 |
|
|
|
1684 |
$count = null;
|
|
|
1685 |
|
|
|
1686 |
if ($this->collAttachments === null) {
|
|
|
1687 |
if ($this->isNew()) {
|
|
|
1688 |
$count = 0;
|
|
|
1689 |
} else {
|
|
|
1690 |
|
|
|
1691 |
$criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
|
|
|
1692 |
|
|
|
1693 |
$count = AttachmentPeer::doCount($criteria, false, $con);
|
|
|
1694 |
}
|
|
|
1695 |
} else {
|
|
|
1696 |
// criteria has no effect for a new object
|
|
|
1697 |
if (!$this->isNew()) {
|
|
|
1698 |
// the following code is to determine if a new query is
|
|
|
1699 |
// called for. If the criteria is the same as the last
|
|
|
1700 |
// one, just return count of the collection.
|
|
|
1701 |
|
|
|
1702 |
|
|
|
1703 |
$criteria->add(AttachmentPeer::ARTICLE_ID, $this->id);
|
|
|
1704 |
|
|
|
1705 |
if (!isset($this->lastAttachmentCriteria) || !$this->lastAttachmentCriteria->equals($criteria)) {
|
|
|
1706 |
$count = AttachmentPeer::doCount($criteria, false, $con);
|
|
|
1707 |
} else {
|
|
|
1708 |
$count = count($this->collAttachments);
|
|
|
1709 |
}
|
|
|
1710 |
} else {
|
|
|
1711 |
$count = count($this->collAttachments);
|
|
|
1712 |
}
|
|
|
1713 |
}
|
|
|
1714 |
return $count;
|
|
|
1715 |
}
|
|
|
1716 |
|
|
|
1717 |
/**
|
|
|
1718 |
* Method called to associate a Attachment object to this object
|
|
|
1719 |
* through the Attachment foreign key attribute.
|
|
|
1720 |
*
|
|
|
1721 |
* @param Attachment $l Attachment
|
|
|
1722 |
* @return void
|
|
|
1723 |
* @throws PropelException
|
|
|
1724 |
*/
|
|
|
1725 |
public function addAttachment(Attachment $l)
|
|
|
1726 |
{
|
|
|
1727 |
if ($this->collAttachments === null) {
|
|
|
1728 |
$this->initAttachments();
|
|
|
1729 |
}
|
|
|
1730 |
if (!in_array($l, $this->collAttachments, true)) { // only add it if the **same** object is not already associated
|
|
|
1731 |
array_push($this->collAttachments, $l);
|
|
|
1732 |
$l->setArticle($this);
|
|
|
1733 |
}
|
|
|
1734 |
}
|
|
|
1735 |
|
|
|
1736 |
/**
|
|
|
1737 |
* Resets all collections of referencing foreign keys.
|
|
|
1738 |
*
|
|
|
1739 |
* This method is a user-space workaround for PHP's inability to garbage collect objects
|
|
|
1740 |
* with circular references. This is currently necessary when using Propel in certain
|
|
|
1741 |
* daemon or large-volumne/high-memory operations.
|
|
|
1742 |
*
|
|
|
1743 |
* @param boolean $deep Whether to also clear the references on all associated objects.
|
|
|
1744 |
*/
|
|
|
1745 |
public function clearAllReferences($deep = false)
|
|
|
1746 |
{
|
|
|
1747 |
if ($deep) {
|
|
|
1748 |
if ($this->collAuthorArticles) {
|
|
|
1749 |
foreach ((array) $this->collAuthorArticles as $o) {
|
|
|
1750 |
$o->clearAllReferences($deep);
|
|
|
1751 |
}
|
|
|
1752 |
}
|
|
|
1753 |
if ($this->collAttachments) {
|
|
|
1754 |
foreach ((array) $this->collAttachments as $o) {
|
|
|
1755 |
$o->clearAllReferences($deep);
|
|
|
1756 |
}
|
|
|
1757 |
}
|
|
|
1758 |
} // if ($deep)
|
|
|
1759 |
|
|
|
1760 |
$this->collAuthorArticles = null;
|
|
|
1761 |
$this->collAttachments = null;
|
|
|
1762 |
$this->aCategory = null;
|
|
|
1763 |
$this->aBook = null;
|
|
|
1764 |
}
|
|
|
1765 |
|
|
|
1766 |
// symfony_behaviors behavior
|
|
|
1767 |
|
|
|
1768 |
/**
|
|
|
1769 |
* Calls methods defined via {@link sfMixer}.
|
|
|
1770 |
*/
|
|
|
1771 |
public function __call($method, $arguments)
|
|
|
1772 |
{
|
|
|
1773 |
if (!$callable = sfMixer::getCallable('BaseArticle:'.$method))
|
|
|
1774 |
{
|
|
|
1775 |
throw new sfException(sprintf('Call to undefined method BaseArticle::%s', $method));
|
|
|
1776 |
}
|
|
|
1777 |
|
|
|
1778 |
array_unshift($arguments, $this);
|
|
|
1779 |
|
|
|
1780 |
return call_user_func_array($callable, $arguments);
|
|
|
1781 |
}
|
|
|
1782 |
|
|
|
1783 |
} // BaseArticle
|