Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
/**
4
 * Base class that represents a row from the 'author_article' table.
5
 *
6
 *
7
 *
8
 * This class was autogenerated by Propel 1.4.2 on:
9
 *
10
 * Fri Aug  5 09:39:37 2011
11
 *
12
 * @package    lib.model.om
13
 */
14
abstract class BaseAuthorArticle 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        AuthorArticlePeer
22
	 */
23
	protected static $peer;
24
 
25
	/**
26
	 * The value for the author_id field.
27
	 * @var        int
28
	 */
29
	protected $author_id;
30
 
31
	/**
32
	 * The value for the article_id field.
33
	 * @var        int
34
	 */
35
	protected $article_id;
36
 
37
	/**
38
	 * @var        Author
39
	 */
40
	protected $aAuthor;
41
 
42
	/**
43
	 * @var        Article
44
	 */
45
	protected $aArticle;
46
 
47
	/**
48
	 * Flag to prevent endless save loop, if this object is referenced
49
	 * by another object which falls in this transaction.
50
	 * @var        boolean
51
	 */
52
	protected $alreadyInSave = false;
53
 
54
	/**
55
	 * Flag to prevent endless validation loop, if this object is referenced
56
	 * by another object which falls in this transaction.
57
	 * @var        boolean
58
	 */
59
	protected $alreadyInValidation = false;
60
 
61
	// symfony behavior
62
 
63
	const PEER = 'AuthorArticlePeer';
64
 
65
	/**
66
	 * Get the [author_id] column value.
67
	 *
68
	 * @return     int
69
	 */
70
	public function getAuthorId()
71
	{
72
		return $this->author_id;
73
	}
74
 
75
	/**
76
	 * Get the [article_id] column value.
77
	 *
78
	 * @return     int
79
	 */
80
	public function getArticleId()
81
	{
82
		return $this->article_id;
83
	}
84
 
85
	/**
86
	 * Set the value of [author_id] column.
87
	 *
88
	 * @param      int $v new value
89
	 * @return     AuthorArticle The current object (for fluent API support)
90
	 */
91
	public function setAuthorId($v)
92
	{
93
		if ($v !== null) {
94
			$v = (int) $v;
95
		}
96
 
97
		if ($this->author_id !== $v) {
98
			$this->author_id = $v;
99
			$this->modifiedColumns[] = AuthorArticlePeer::AUTHOR_ID;
100
		}
101
 
102
		if ($this->aAuthor !== null && $this->aAuthor->getId() !== $v) {
103
			$this->aAuthor = null;
104
		}
105
 
106
		return $this;
107
	} // setAuthorId()
108
 
109
	/**
110
	 * Set the value of [article_id] column.
111
	 *
112
	 * @param      int $v new value
113
	 * @return     AuthorArticle The current object (for fluent API support)
114
	 */
115
	public function setArticleId($v)
116
	{
117
		if ($v !== null) {
118
			$v = (int) $v;
119
		}
120
 
121
		if ($this->article_id !== $v) {
122
			$this->article_id = $v;
123
			$this->modifiedColumns[] = AuthorArticlePeer::ARTICLE_ID;
124
		}
125
 
126
		if ($this->aArticle !== null && $this->aArticle->getId() !== $v) {
127
			$this->aArticle = null;
128
		}
129
 
130
		return $this;
131
	} // setArticleId()
132
 
133
	/**
134
	 * Indicates whether the columns in this object are only set to default values.
135
	 *
136
	 * This method can be used in conjunction with isModified() to indicate whether an object is both
137
	 * modified _and_ has some values set which are non-default.
138
	 *
139
	 * @return     boolean Whether the columns in this object are only been set with default values.
140
	 */
141
	public function hasOnlyDefaultValues()
142
	{
143
		// otherwise, everything was equal, so return TRUE
144
		return true;
145
	} // hasOnlyDefaultValues()
146
 
147
	/**
148
	 * Hydrates (populates) the object variables with values from the database resultset.
149
	 *
150
	 * An offset (0-based "start column") is specified so that objects can be hydrated
151
	 * with a subset of the columns in the resultset rows.  This is needed, for example,
152
	 * for results of JOIN queries where the resultset row includes columns from two or
153
	 * more tables.
154
	 *
155
	 * @param      array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
156
	 * @param      int $startcol 0-based offset column which indicates which restultset column to start with.
157
	 * @param      boolean $rehydrate Whether this object is being re-hydrated from the database.
158
	 * @return     int next starting column
159
	 * @throws     PropelException  - Any caught Exception will be rewrapped as a PropelException.
160
	 */
161
	public function hydrate($row, $startcol = 0, $rehydrate = false)
162
	{
163
		try {
164
 
165
			$this->author_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
166
			$this->article_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
167
			$this->resetModified();
168
 
169
			$this->setNew(false);
170
 
171
			if ($rehydrate) {
172
				$this->ensureConsistency();
173
			}
174
 
175
			// FIXME - using NUM_COLUMNS may be clearer.
176
			return $startcol + 2; // 2 = AuthorArticlePeer::NUM_COLUMNS - AuthorArticlePeer::NUM_LAZY_LOAD_COLUMNS).
177
 
178
		} catch (Exception $e) {
179
			throw new PropelException("Error populating AuthorArticle object", $e);
180
		}
181
	}
182
 
183
	/**
184
	 * Checks and repairs the internal consistency of the object.
185
	 *
186
	 * This method is executed after an already-instantiated object is re-hydrated
187
	 * from the database.  It exists to check any foreign keys to make sure that
188
	 * the objects related to the current object are correct based on foreign key.
189
	 *
190
	 * You can override this method in the stub class, but you should always invoke
191
	 * the base method from the overridden method (i.e. parent::ensureConsistency()),
192
	 * in case your model changes.
193
	 *
194
	 * @throws     PropelException
195
	 */
196
	public function ensureConsistency()
197
	{
198
 
199
		if ($this->aAuthor !== null && $this->author_id !== $this->aAuthor->getId()) {
200
			$this->aAuthor = null;
201
		}
202
		if ($this->aArticle !== null && $this->article_id !== $this->aArticle->getId()) {
203
			$this->aArticle = null;
204
		}
205
	} // ensureConsistency
206
 
207
	/**
208
	 * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
209
	 *
210
	 * This will only work if the object has been saved and has a valid primary key set.
211
	 *
212
	 * @param      boolean $deep (optional) Whether to also de-associated any related objects.
213
	 * @param      PropelPDO $con (optional) The PropelPDO connection to use.
214
	 * @return     void
215
	 * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
216
	 */
217
	public function reload($deep = false, PropelPDO $con = null)
218
	{
219
		if ($this->isDeleted()) {
220
			throw new PropelException("Cannot reload a deleted object.");
221
		}
222
 
223
		if ($this->isNew()) {
224
			throw new PropelException("Cannot reload an unsaved object.");
225
		}
226
 
227
		if ($con === null) {
228
			$con = Propel::getConnection(AuthorArticlePeer::DATABASE_NAME, Propel::CONNECTION_READ);
229
		}
230
 
231
		// We don't need to alter the object instance pool; we're just modifying this instance
232
		// already in the pool.
233
 
234
		$stmt = AuthorArticlePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
235
		$row = $stmt->fetch(PDO::FETCH_NUM);
236
		$stmt->closeCursor();
237
		if (!$row) {
238
			throw new PropelException('Cannot find matching row in the database to reload object values.');
239
		}
240
		$this->hydrate($row, 0, true); // rehydrate
241
 
242
		if ($deep) {  // also de-associate any related objects?
243
 
244
			$this->aAuthor = null;
245
			$this->aArticle = null;
246
		} // if (deep)
247
	}
248
 
249
	/**
250
	 * Removes this object from datastore and sets delete attribute.
251
	 *
252
	 * @param      PropelPDO $con
253
	 * @return     void
254
	 * @throws     PropelException
255
	 * @see        BaseObject::setDeleted()
256
	 * @see        BaseObject::isDeleted()
257
	 */
258
	public function delete(PropelPDO $con = null)
259
	{
260
		if ($this->isDeleted()) {
261
			throw new PropelException("This object has already been deleted.");
262
		}
263
 
264
		if ($con === null) {
265
			$con = Propel::getConnection(AuthorArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
266
		}
267
 
268
		$con->beginTransaction();
269
		try {
270
			$ret = $this->preDelete($con);
271
			// symfony_behaviors behavior
272
			foreach (sfMixer::getCallables('BaseAuthorArticle:delete:pre') as $callable)
273
			{
274
			  if (call_user_func($callable, $this, $con))
275
			  {
276
			    $con->commit();
277
 
278
			    return;
279
			  }
280
			}
281
 
282
			if ($ret) {
283
				AuthorArticlePeer::doDelete($this, $con);
284
				$this->postDelete($con);
285
				// symfony_behaviors behavior
286
				foreach (sfMixer::getCallables('BaseAuthorArticle:delete:post') as $callable)
287
				{
288
				  call_user_func($callable, $this, $con);
289
				}
290
 
291
				$this->setDeleted(true);
292
				$con->commit();
293
			} else {
294
				$con->commit();
295
			}
296
		} catch (PropelException $e) {
297
			$con->rollBack();
298
			throw $e;
299
		}
300
	}
301
 
302
	/**
303
	 * Persists this object to the database.
304
	 *
305
	 * If the object is new, it inserts it; otherwise an update is performed.
306
	 * All modified related objects will also be persisted in the doSave()
307
	 * method.  This method wraps all precipitate database operations in a
308
	 * single transaction.
309
	 *
310
	 * @param      PropelPDO $con
311
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
312
	 * @throws     PropelException
313
	 * @see        doSave()
314
	 */
315
	public function save(PropelPDO $con = null)
316
	{
317
		if ($this->isDeleted()) {
318
			throw new PropelException("You cannot save an object that has been deleted.");
319
		}
320
 
321
		if ($con === null) {
322
			$con = Propel::getConnection(AuthorArticlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
323
		}
324
 
325
		$con->beginTransaction();
326
		$isInsert = $this->isNew();
327
		try {
328
			$ret = $this->preSave($con);
329
			// symfony_behaviors behavior
330
			foreach (sfMixer::getCallables('BaseAuthorArticle:save:pre') as $callable)
331
			{
332
			  if (is_integer($affectedRows = call_user_func($callable, $this, $con)))
333
			  {
334
			    $con->commit();
335
 
336
			    return $affectedRows;
337
			  }
338
			}
339
 
340
			if ($isInsert) {
341
				$ret = $ret && $this->preInsert($con);
342
			} else {
343
				$ret = $ret && $this->preUpdate($con);
344
			}
345
			if ($ret) {
346
				$affectedRows = $this->doSave($con);
347
				if ($isInsert) {
348
					$this->postInsert($con);
349
				} else {
350
					$this->postUpdate($con);
351
				}
352
				$this->postSave($con);
353
				// symfony_behaviors behavior
354
				foreach (sfMixer::getCallables('BaseAuthorArticle:save:post') as $callable)
355
				{
356
				  call_user_func($callable, $this, $con, $affectedRows);
357
				}
358
 
359
				AuthorArticlePeer::addInstanceToPool($this);
360
			} else {
361
				$affectedRows = 0;
362
			}
363
			$con->commit();
364
			return $affectedRows;
365
		} catch (PropelException $e) {
366
			$con->rollBack();
367
			throw $e;
368
		}
369
	}
370
 
371
	/**
372
	 * Performs the work of inserting or updating the row in the database.
373
	 *
374
	 * If the object is new, it inserts it; otherwise an update is performed.
375
	 * All related objects are also updated in this method.
376
	 *
377
	 * @param      PropelPDO $con
378
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
379
	 * @throws     PropelException
380
	 * @see        save()
381
	 */
382
	protected function doSave(PropelPDO $con)
383
	{
384
		$affectedRows = 0; // initialize var to track total num of affected rows
385
		if (!$this->alreadyInSave) {
386
			$this->alreadyInSave = true;
387
 
388
			// We call the save method on the following object(s) if they
389
			// were passed to this object by their coresponding set
390
			// method.  This object relates to these object(s) by a
391
			// foreign key reference.
392
 
393
			if ($this->aAuthor !== null) {
394
				if ($this->aAuthor->isModified() || $this->aAuthor->isNew()) {
395
					$affectedRows += $this->aAuthor->save($con);
396
				}
397
				$this->setAuthor($this->aAuthor);
398
			}
399
 
400
			if ($this->aArticle !== null) {
401
				if ($this->aArticle->isModified() || $this->aArticle->isNew()) {
402
					$affectedRows += $this->aArticle->save($con);
403
				}
404
				$this->setArticle($this->aArticle);
405
			}
406
 
407
 
408
			// If this object has been modified, then save it to the database.
409
			if ($this->isModified()) {
410
				if ($this->isNew()) {
411
					$pk = AuthorArticlePeer::doInsert($this, $con);
412
					$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
413
										 // should always be true here (even though technically
414
										 // BasePeer::doInsert() can insert multiple rows).
415
 
416
					$this->setNew(false);
417
				} else {
418
					$affectedRows += AuthorArticlePeer::doUpdate($this, $con);
419
				}
420
 
421
				$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
422
			}
423
 
424
			$this->alreadyInSave = false;
425
 
426
		}
427
		return $affectedRows;
428
	} // doSave()
429
 
430
	/**
431
	 * Array of ValidationFailed objects.
432
	 * @var        array ValidationFailed[]
433
	 */
434
	protected $validationFailures = array();
435
 
436
	/**
437
	 * Gets any ValidationFailed objects that resulted from last call to validate().
438
	 *
439
	 *
440
	 * @return     array ValidationFailed[]
441
	 * @see        validate()
442
	 */
443
	public function getValidationFailures()
444
	{
445
		return $this->validationFailures;
446
	}
447
 
448
	/**
449
	 * Validates the objects modified field values and all objects related to this table.
450
	 *
451
	 * If $columns is either a column name or an array of column names
452
	 * only those columns are validated.
453
	 *
454
	 * @param      mixed $columns Column name or an array of column names.
455
	 * @return     boolean Whether all columns pass validation.
456
	 * @see        doValidate()
457
	 * @see        getValidationFailures()
458
	 */
459
	public function validate($columns = null)
460
	{
461
		$res = $this->doValidate($columns);
462
		if ($res === true) {
463
			$this->validationFailures = array();
464
			return true;
465
		} else {
466
			$this->validationFailures = $res;
467
			return false;
468
		}
469
	}
470
 
471
	/**
472
	 * This function performs the validation work for complex object models.
473
	 *
474
	 * In addition to checking the current object, all related objects will
475
	 * also be validated.  If all pass then <code>true</code> is returned; otherwise
476
	 * an aggreagated array of ValidationFailed objects will be returned.
477
	 *
478
	 * @param      array $columns Array of column names to validate.
479
	 * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
480
	 */
481
	protected function doValidate($columns = null)
482
	{
483
		if (!$this->alreadyInValidation) {
484
			$this->alreadyInValidation = true;
485
			$retval = null;
486
 
487
			$failureMap = array();
488
 
489
 
490
			// We call the validate method on the following object(s) if they
491
			// were passed to this object by their coresponding set
492
			// method.  This object relates to these object(s) by a
493
			// foreign key reference.
494
 
495
			if ($this->aAuthor !== null) {
496
				if (!$this->aAuthor->validate($columns)) {
497
					$failureMap = array_merge($failureMap, $this->aAuthor->getValidationFailures());
498
				}
499
			}
500
 
501
			if ($this->aArticle !== null) {
502
				if (!$this->aArticle->validate($columns)) {
503
					$failureMap = array_merge($failureMap, $this->aArticle->getValidationFailures());
504
				}
505
			}
506
 
507
 
508
			if (($retval = AuthorArticlePeer::doValidate($this, $columns)) !== true) {
509
				$failureMap = array_merge($failureMap, $retval);
510
			}
511
 
512
 
513
 
514
			$this->alreadyInValidation = false;
515
		}
516
 
517
		return (!empty($failureMap) ? $failureMap : true);
518
	}
519
 
520
	/**
521
	 * Retrieves a field from the object by name passed in as a string.
522
	 *
523
	 * @param      string $name name
524
	 * @param      string $type The type of fieldname the $name is of:
525
	 *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
526
	 *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
527
	 * @return     mixed Value of field.
528
	 */
529
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
530
	{
531
		$pos = AuthorArticlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
532
		$field = $this->getByPosition($pos);
533
		return $field;
534
	}
535
 
536
	/**
537
	 * Retrieves a field from the object by Position as specified in the xml schema.
538
	 * Zero-based.
539
	 *
540
	 * @param      int $pos position in xml schema
541
	 * @return     mixed Value of field at $pos
542
	 */
543
	public function getByPosition($pos)
544
	{
545
		switch($pos) {
546
			case 0:
547
				return $this->getAuthorId();
548
				break;
549
			case 1:
550
				return $this->getArticleId();
551
				break;
552
			default:
553
				return null;
554
				break;
555
		} // switch()
556
	}
557
 
558
	/**
559
	 * Exports the object as an array.
560
	 *
561
	 * You can specify the key type of the array by passing one of the class
562
	 * type constants.
563
	 *
564
	 * @param      string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
565
	 *                        BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
566
	 * @param      boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns.  Defaults to TRUE.
567
	 * @return     an associative array containing the field names (as keys) and field values
568
	 */
569
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
570
	{
571
		$keys = AuthorArticlePeer::getFieldNames($keyType);
572
		$result = array(
573
			$keys[0] => $this->getAuthorId(),
574
			$keys[1] => $this->getArticleId(),
575
		);
576
		return $result;
577
	}
578
 
579
	/**
580
	 * Sets a field from the object by name passed in as a string.
581
	 *
582
	 * @param      string $name peer name
583
	 * @param      mixed $value field value
584
	 * @param      string $type The type of fieldname the $name is of:
585
	 *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
586
	 *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
587
	 * @return     void
588
	 */
589
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
590
	{
591
		$pos = AuthorArticlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
592
		return $this->setByPosition($pos, $value);
593
	}
594
 
595
	/**
596
	 * Sets a field from the object by Position as specified in the xml schema.
597
	 * Zero-based.
598
	 *
599
	 * @param      int $pos position in xml schema
600
	 * @param      mixed $value field value
601
	 * @return     void
602
	 */
603
	public function setByPosition($pos, $value)
604
	{
605
		switch($pos) {
606
			case 0:
607
				$this->setAuthorId($value);
608
				break;
609
			case 1:
610
				$this->setArticleId($value);
611
				break;
612
		} // switch()
613
	}
614
 
615
	/**
616
	 * Populates the object using an array.
617
	 *
618
	 * This is particularly useful when populating an object from one of the
619
	 * request arrays (e.g. $_POST).  This method goes through the column
620
	 * names, checking to see whether a matching key exists in populated
621
	 * array. If so the setByName() method is called for that column.
622
	 *
623
	 * You can specify the key type of the array by additionally passing one
624
	 * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
625
	 * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
626
	 * The default key type is the column's phpname (e.g. 'AuthorId')
627
	 *
628
	 * @param      array  $arr     An array to populate the object from.
629
	 * @param      string $keyType The type of keys the array uses.
630
	 * @return     void
631
	 */
632
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
633
	{
634
		$keys = AuthorArticlePeer::getFieldNames($keyType);
635
 
636
		if (array_key_exists($keys[0], $arr)) $this->setAuthorId($arr[$keys[0]]);
637
		if (array_key_exists($keys[1], $arr)) $this->setArticleId($arr[$keys[1]]);
638
	}
639
 
640
	/**
641
	 * Build a Criteria object containing the values of all modified columns in this object.
642
	 *
643
	 * @return     Criteria The Criteria object containing all modified values.
644
	 */
645
	public function buildCriteria()
646
	{
647
		$criteria = new Criteria(AuthorArticlePeer::DATABASE_NAME);
648
 
649
		if ($this->isColumnModified(AuthorArticlePeer::AUTHOR_ID)) $criteria->add(AuthorArticlePeer::AUTHOR_ID, $this->author_id);
650
		if ($this->isColumnModified(AuthorArticlePeer::ARTICLE_ID)) $criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->article_id);
651
 
652
		return $criteria;
653
	}
654
 
655
	/**
656
	 * Builds a Criteria object containing the primary key for this object.
657
	 *
658
	 * Unlike buildCriteria() this method includes the primary key values regardless
659
	 * of whether or not they have been modified.
660
	 *
661
	 * @return     Criteria The Criteria object containing value(s) for primary key(s).
662
	 */
663
	public function buildPkeyCriteria()
664
	{
665
		$criteria = new Criteria(AuthorArticlePeer::DATABASE_NAME);
666
 
667
		$criteria->add(AuthorArticlePeer::AUTHOR_ID, $this->author_id);
668
		$criteria->add(AuthorArticlePeer::ARTICLE_ID, $this->article_id);
669
 
670
		return $criteria;
671
	}
672
 
673
	/**
674
	 * Returns the composite primary key for this object.
675
	 * The array elements will be in same order as specified in XML.
676
	 * @return     array
677
	 */
678
	public function getPrimaryKey()
679
	{
680
		$pks = array();
681
 
682
		$pks[0] = $this->getAuthorId();
683
 
684
		$pks[1] = $this->getArticleId();
685
 
686
		return $pks;
687
	}
688
 
689
	/**
690
	 * Set the [composite] primary key.
691
	 *
692
	 * @param      array $keys The elements of the composite key (order must match the order in XML file).
693
	 * @return     void
694
	 */
695
	public function setPrimaryKey($keys)
696
	{
697
 
698
		$this->setAuthorId($keys[0]);
699
 
700
		$this->setArticleId($keys[1]);
701
 
702
	}
703
 
704
	/**
705
	 * Sets contents of passed object to values from current object.
706
	 *
707
	 * If desired, this method can also make copies of all associated (fkey referrers)
708
	 * objects.
709
	 *
710
	 * @param      object $copyObj An object of AuthorArticle (or compatible) type.
711
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
712
	 * @throws     PropelException
713
	 */
714
	public function copyInto($copyObj, $deepCopy = false)
715
	{
716
 
717
		$copyObj->setAuthorId($this->author_id);
718
 
719
		$copyObj->setArticleId($this->article_id);
720
 
721
 
722
		$copyObj->setNew(true);
723
 
724
	}
725
 
726
	/**
727
	 * Makes a copy of this object that will be inserted as a new row in table when saved.
728
	 * It creates a new object filling in the simple attributes, but skipping any primary
729
	 * keys that are defined for the table.
730
	 *
731
	 * If desired, this method can also make copies of all associated (fkey referrers)
732
	 * objects.
733
	 *
734
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
735
	 * @return     AuthorArticle Clone of current object.
736
	 * @throws     PropelException
737
	 */
738
	public function copy($deepCopy = false)
739
	{
740
		// we use get_class(), because this might be a subclass
741
		$clazz = get_class($this);
742
		$copyObj = new $clazz();
743
		$this->copyInto($copyObj, $deepCopy);
744
		return $copyObj;
745
	}
746
 
747
	/**
748
	 * Returns a peer instance associated with this om.
749
	 *
750
	 * Since Peer classes are not to have any instance attributes, this method returns the
751
	 * same instance for all member of this class. The method could therefore
752
	 * be static, but this would prevent one from overriding the behavior.
753
	 *
754
	 * @return     AuthorArticlePeer
755
	 */
756
	public function getPeer()
757
	{
758
		if (self::$peer === null) {
759
			self::$peer = new AuthorArticlePeer();
760
		}
761
		return self::$peer;
762
	}
763
 
764
	/**
765
	 * Declares an association between this object and a Author object.
766
	 *
767
	 * @param      Author $v
768
	 * @return     AuthorArticle The current object (for fluent API support)
769
	 * @throws     PropelException
770
	 */
771
	public function setAuthor(Author $v = null)
772
	{
773
		if ($v === null) {
774
			$this->setAuthorId(NULL);
775
		} else {
776
			$this->setAuthorId($v->getId());
777
		}
778
 
779
		$this->aAuthor = $v;
780
 
781
		// Add binding for other direction of this n:n relationship.
782
		// If this object has already been added to the Author object, it will not be re-added.
783
		if ($v !== null) {
784
			$v->addAuthorArticle($this);
785
		}
786
 
787
		return $this;
788
	}
789
 
790
 
791
	/**
792
	 * Get the associated Author object
793
	 *
794
	 * @param      PropelPDO Optional Connection object.
795
	 * @return     Author The associated Author object.
796
	 * @throws     PropelException
797
	 */
798
	public function getAuthor(PropelPDO $con = null)
799
	{
800
		if ($this->aAuthor === null && ($this->author_id !== null)) {
801
			$this->aAuthor = AuthorPeer::retrieveByPk($this->author_id);
802
			/* The following can be used additionally to
803
			   guarantee the related object contains a reference
804
			   to this object.  This level of coupling may, however, be
805
			   undesirable since it could result in an only partially populated collection
806
			   in the referenced object.
807
			   $this->aAuthor->addAuthorArticles($this);
808
			 */
809
		}
810
		return $this->aAuthor;
811
	}
812
 
813
	/**
814
	 * Declares an association between this object and a Article object.
815
	 *
816
	 * @param      Article $v
817
	 * @return     AuthorArticle The current object (for fluent API support)
818
	 * @throws     PropelException
819
	 */
820
	public function setArticle(Article $v = null)
821
	{
822
		if ($v === null) {
823
			$this->setArticleId(NULL);
824
		} else {
825
			$this->setArticleId($v->getId());
826
		}
827
 
828
		$this->aArticle = $v;
829
 
830
		// Add binding for other direction of this n:n relationship.
831
		// If this object has already been added to the Article object, it will not be re-added.
832
		if ($v !== null) {
833
			$v->addAuthorArticle($this);
834
		}
835
 
836
		return $this;
837
	}
838
 
839
 
840
	/**
841
	 * Get the associated Article object
842
	 *
843
	 * @param      PropelPDO Optional Connection object.
844
	 * @return     Article The associated Article object.
845
	 * @throws     PropelException
846
	 */
847
	public function getArticle(PropelPDO $con = null)
848
	{
849
		if ($this->aArticle === null && ($this->article_id !== null)) {
850
			$this->aArticle = ArticlePeer::retrieveByPk($this->article_id);
851
			/* The following can be used additionally to
852
			   guarantee the related object contains a reference
853
			   to this object.  This level of coupling may, however, be
854
			   undesirable since it could result in an only partially populated collection
855
			   in the referenced object.
856
			   $this->aArticle->addAuthorArticles($this);
857
			 */
858
		}
859
		return $this->aArticle;
860
	}
861
 
862
	/**
863
	 * Resets all collections of referencing foreign keys.
864
	 *
865
	 * This method is a user-space workaround for PHP's inability to garbage collect objects
866
	 * with circular references.  This is currently necessary when using Propel in certain
867
	 * daemon or large-volumne/high-memory operations.
868
	 *
869
	 * @param      boolean $deep Whether to also clear the references on all associated objects.
870
	 */
871
	public function clearAllReferences($deep = false)
872
	{
873
		if ($deep) {
874
		} // if ($deep)
875
 
876
			$this->aAuthor = null;
877
			$this->aArticle = null;
878
	}
879
 
880
	// symfony_behaviors behavior
881
 
882
	/**
883
	 * Calls methods defined via {@link sfMixer}.
884
	 */
885
	public function __call($method, $arguments)
886
	{
887
	  if (!$callable = sfMixer::getCallable('BaseAuthorArticle:'.$method))
888
	  {
889
	    throw new sfException(sprintf('Call to undefined method BaseAuthorArticle::%s', $method));
890
	  }
891
 
892
	  array_unshift($arguments, $this);
893
 
894
	  return call_user_func_array($callable, $arguments);
895
	}
896
 
897
} // BaseAuthorArticle