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 'movie' table.
5
 *
6
 *
7
 *
8
 * This class was autogenerated by Propel 1.4.2 on:
9
 *
10
 * Fri Aug  5 09:39:38 2011
11
 *
12
 * @package    lib.model.om
13
 */
14
abstract class BaseMovie 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        MoviePeer
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 director field.
33
	 * @var        string
34
	 */
35
	protected $director;
36
 
37
	/**
38
	 * @var        array MovieI18n[] Collection to store aggregation of MovieI18n objects.
39
	 */
40
	protected $collMovieI18ns;
41
 
42
	/**
43
	 * @var        Criteria The criteria used to select the current contents of collMovieI18ns.
44
	 */
45
	private $lastMovieI18nCriteria = null;
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 = 'MoviePeer';
64
 
65
	// symfony_i18n behavior
66
 
67
	/**
68
	 * @var string The value for the culture field
69
	 */
70
	protected $culture = null;
71
 
72
	/**
73
	 * @var array Current I18N objects
74
	 */
75
	protected $current_i18n = array();
76
 
77
	/**
78
	 * Get the [id] column value.
79
	 *
80
	 * @return     int
81
	 */
82
	public function getId()
83
	{
84
		return $this->id;
85
	}
86
 
87
	/**
88
	 * Get the [director] column value.
89
	 *
90
	 * @return     string
91
	 */
92
	public function getDirector()
93
	{
94
		return $this->director;
95
	}
96
 
97
	/**
98
	 * Set the value of [id] column.
99
	 *
100
	 * @param      int $v new value
101
	 * @return     Movie The current object (for fluent API support)
102
	 */
103
	public function setId($v)
104
	{
105
		if ($v !== null) {
106
			$v = (int) $v;
107
		}
108
 
109
		if ($this->id !== $v) {
110
			$this->id = $v;
111
			$this->modifiedColumns[] = MoviePeer::ID;
112
		}
113
 
114
		return $this;
115
	} // setId()
116
 
117
	/**
118
	 * Set the value of [director] column.
119
	 *
120
	 * @param      string $v new value
121
	 * @return     Movie The current object (for fluent API support)
122
	 */
123
	public function setDirector($v)
124
	{
125
		if ($v !== null) {
126
			$v = (string) $v;
127
		}
128
 
129
		if ($this->director !== $v) {
130
			$this->director = $v;
131
			$this->modifiedColumns[] = MoviePeer::DIRECTOR;
132
		}
133
 
134
		return $this;
135
	} // setDirector()
136
 
137
	/**
138
	 * Indicates whether the columns in this object are only set to default values.
139
	 *
140
	 * This method can be used in conjunction with isModified() to indicate whether an object is both
141
	 * modified _and_ has some values set which are non-default.
142
	 *
143
	 * @return     boolean Whether the columns in this object are only been set with default values.
144
	 */
145
	public function hasOnlyDefaultValues()
146
	{
147
		// otherwise, everything was equal, so return TRUE
148
		return true;
149
	} // hasOnlyDefaultValues()
150
 
151
	/**
152
	 * Hydrates (populates) the object variables with values from the database resultset.
153
	 *
154
	 * An offset (0-based "start column") is specified so that objects can be hydrated
155
	 * with a subset of the columns in the resultset rows.  This is needed, for example,
156
	 * for results of JOIN queries where the resultset row includes columns from two or
157
	 * more tables.
158
	 *
159
	 * @param      array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
160
	 * @param      int $startcol 0-based offset column which indicates which restultset column to start with.
161
	 * @param      boolean $rehydrate Whether this object is being re-hydrated from the database.
162
	 * @return     int next starting column
163
	 * @throws     PropelException  - Any caught Exception will be rewrapped as a PropelException.
164
	 */
165
	public function hydrate($row, $startcol = 0, $rehydrate = false)
166
	{
167
		try {
168
 
169
			$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
170
			$this->director = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
171
			$this->resetModified();
172
 
173
			$this->setNew(false);
174
 
175
			if ($rehydrate) {
176
				$this->ensureConsistency();
177
			}
178
 
179
			// FIXME - using NUM_COLUMNS may be clearer.
180
			return $startcol + 2; // 2 = MoviePeer::NUM_COLUMNS - MoviePeer::NUM_LAZY_LOAD_COLUMNS).
181
 
182
		} catch (Exception $e) {
183
			throw new PropelException("Error populating Movie object", $e);
184
		}
185
	}
186
 
187
	/**
188
	 * Checks and repairs the internal consistency of the object.
189
	 *
190
	 * This method is executed after an already-instantiated object is re-hydrated
191
	 * from the database.  It exists to check any foreign keys to make sure that
192
	 * the objects related to the current object are correct based on foreign key.
193
	 *
194
	 * You can override this method in the stub class, but you should always invoke
195
	 * the base method from the overridden method (i.e. parent::ensureConsistency()),
196
	 * in case your model changes.
197
	 *
198
	 * @throws     PropelException
199
	 */
200
	public function ensureConsistency()
201
	{
202
 
203
	} // ensureConsistency
204
 
205
	/**
206
	 * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
207
	 *
208
	 * This will only work if the object has been saved and has a valid primary key set.
209
	 *
210
	 * @param      boolean $deep (optional) Whether to also de-associated any related objects.
211
	 * @param      PropelPDO $con (optional) The PropelPDO connection to use.
212
	 * @return     void
213
	 * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
214
	 */
215
	public function reload($deep = false, PropelPDO $con = null)
216
	{
217
		if ($this->isDeleted()) {
218
			throw new PropelException("Cannot reload a deleted object.");
219
		}
220
 
221
		if ($this->isNew()) {
222
			throw new PropelException("Cannot reload an unsaved object.");
223
		}
224
 
225
		if ($con === null) {
226
			$con = Propel::getConnection(MoviePeer::DATABASE_NAME, Propel::CONNECTION_READ);
227
		}
228
 
229
		// We don't need to alter the object instance pool; we're just modifying this instance
230
		// already in the pool.
231
 
232
		$stmt = MoviePeer::doSelectStmt($this->buildPkeyCriteria(), $con);
233
		$row = $stmt->fetch(PDO::FETCH_NUM);
234
		$stmt->closeCursor();
235
		if (!$row) {
236
			throw new PropelException('Cannot find matching row in the database to reload object values.');
237
		}
238
		$this->hydrate($row, 0, true); // rehydrate
239
 
240
		if ($deep) {  // also de-associate any related objects?
241
 
242
			$this->collMovieI18ns = null;
243
			$this->lastMovieI18nCriteria = null;
244
 
245
		} // if (deep)
246
	}
247
 
248
	/**
249
	 * Removes this object from datastore and sets delete attribute.
250
	 *
251
	 * @param      PropelPDO $con
252
	 * @return     void
253
	 * @throws     PropelException
254
	 * @see        BaseObject::setDeleted()
255
	 * @see        BaseObject::isDeleted()
256
	 */
257
	public function delete(PropelPDO $con = null)
258
	{
259
		if ($this->isDeleted()) {
260
			throw new PropelException("This object has already been deleted.");
261
		}
262
 
263
		if ($con === null) {
264
			$con = Propel::getConnection(MoviePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
265
		}
266
 
267
		$con->beginTransaction();
268
		try {
269
			$ret = $this->preDelete($con);
270
			// symfony_behaviors behavior
271
			foreach (sfMixer::getCallables('BaseMovie:delete:pre') as $callable)
272
			{
273
			  if (call_user_func($callable, $this, $con))
274
			  {
275
			    $con->commit();
276
 
277
			    return;
278
			  }
279
			}
280
 
281
			if ($ret) {
282
				MoviePeer::doDelete($this, $con);
283
				$this->postDelete($con);
284
				// symfony_behaviors behavior
285
				foreach (sfMixer::getCallables('BaseMovie:delete:post') as $callable)
286
				{
287
				  call_user_func($callable, $this, $con);
288
				}
289
 
290
				$this->setDeleted(true);
291
				$con->commit();
292
			} else {
293
				$con->commit();
294
			}
295
		} catch (PropelException $e) {
296
			$con->rollBack();
297
			throw $e;
298
		}
299
	}
300
 
301
	/**
302
	 * Persists this object to the database.
303
	 *
304
	 * If the object is new, it inserts it; otherwise an update is performed.
305
	 * All modified related objects will also be persisted in the doSave()
306
	 * method.  This method wraps all precipitate database operations in a
307
	 * single transaction.
308
	 *
309
	 * @param      PropelPDO $con
310
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
311
	 * @throws     PropelException
312
	 * @see        doSave()
313
	 */
314
	public function save(PropelPDO $con = null)
315
	{
316
		if ($this->isDeleted()) {
317
			throw new PropelException("You cannot save an object that has been deleted.");
318
		}
319
 
320
		if ($con === null) {
321
			$con = Propel::getConnection(MoviePeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
322
		}
323
 
324
		$con->beginTransaction();
325
		$isInsert = $this->isNew();
326
		try {
327
			$ret = $this->preSave($con);
328
			// symfony_behaviors behavior
329
			foreach (sfMixer::getCallables('BaseMovie:save:pre') as $callable)
330
			{
331
			  if (is_integer($affectedRows = call_user_func($callable, $this, $con)))
332
			  {
333
			    $con->commit();
334
 
335
			    return $affectedRows;
336
			  }
337
			}
338
 
339
			if ($isInsert) {
340
				$ret = $ret && $this->preInsert($con);
341
			} else {
342
				$ret = $ret && $this->preUpdate($con);
343
			}
344
			if ($ret) {
345
				$affectedRows = $this->doSave($con);
346
				if ($isInsert) {
347
					$this->postInsert($con);
348
				} else {
349
					$this->postUpdate($con);
350
				}
351
				$this->postSave($con);
352
				// symfony_behaviors behavior
353
				foreach (sfMixer::getCallables('BaseMovie:save:post') as $callable)
354
				{
355
				  call_user_func($callable, $this, $con, $affectedRows);
356
				}
357
 
358
				MoviePeer::addInstanceToPool($this);
359
			} else {
360
				$affectedRows = 0;
361
			}
362
			$con->commit();
363
			return $affectedRows;
364
		} catch (PropelException $e) {
365
			$con->rollBack();
366
			throw $e;
367
		}
368
	}
369
 
370
	/**
371
	 * Performs the work of inserting or updating the row in the database.
372
	 *
373
	 * If the object is new, it inserts it; otherwise an update is performed.
374
	 * All related objects are also updated in this method.
375
	 *
376
	 * @param      PropelPDO $con
377
	 * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
378
	 * @throws     PropelException
379
	 * @see        save()
380
	 */
381
	protected function doSave(PropelPDO $con)
382
	{
383
		$affectedRows = 0; // initialize var to track total num of affected rows
384
		if (!$this->alreadyInSave) {
385
			$this->alreadyInSave = true;
386
 
387
			if ($this->isNew() ) {
388
				$this->modifiedColumns[] = MoviePeer::ID;
389
			}
390
 
391
			// If this object has been modified, then save it to the database.
392
			if ($this->isModified()) {
393
				if ($this->isNew()) {
394
					$pk = MoviePeer::doInsert($this, $con);
395
					$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
396
										 // should always be true here (even though technically
397
										 // BasePeer::doInsert() can insert multiple rows).
398
 
399
					$this->setId($pk);  //[IMV] update autoincrement primary key
400
 
401
					$this->setNew(false);
402
				} else {
403
					$affectedRows += MoviePeer::doUpdate($this, $con);
404
				}
405
 
406
				$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
407
			}
408
 
409
			if ($this->collMovieI18ns !== null) {
410
				foreach ($this->collMovieI18ns as $referrerFK) {
411
					if (!$referrerFK->isDeleted()) {
412
						$affectedRows += $referrerFK->save($con);
413
					}
414
				}
415
			}
416
 
417
			$this->alreadyInSave = false;
418
 
419
		}
420
		return $affectedRows;
421
	} // doSave()
422
 
423
	/**
424
	 * Array of ValidationFailed objects.
425
	 * @var        array ValidationFailed[]
426
	 */
427
	protected $validationFailures = array();
428
 
429
	/**
430
	 * Gets any ValidationFailed objects that resulted from last call to validate().
431
	 *
432
	 *
433
	 * @return     array ValidationFailed[]
434
	 * @see        validate()
435
	 */
436
	public function getValidationFailures()
437
	{
438
		return $this->validationFailures;
439
	}
440
 
441
	/**
442
	 * Validates the objects modified field values and all objects related to this table.
443
	 *
444
	 * If $columns is either a column name or an array of column names
445
	 * only those columns are validated.
446
	 *
447
	 * @param      mixed $columns Column name or an array of column names.
448
	 * @return     boolean Whether all columns pass validation.
449
	 * @see        doValidate()
450
	 * @see        getValidationFailures()
451
	 */
452
	public function validate($columns = null)
453
	{
454
		$res = $this->doValidate($columns);
455
		if ($res === true) {
456
			$this->validationFailures = array();
457
			return true;
458
		} else {
459
			$this->validationFailures = $res;
460
			return false;
461
		}
462
	}
463
 
464
	/**
465
	 * This function performs the validation work for complex object models.
466
	 *
467
	 * In addition to checking the current object, all related objects will
468
	 * also be validated.  If all pass then <code>true</code> is returned; otherwise
469
	 * an aggreagated array of ValidationFailed objects will be returned.
470
	 *
471
	 * @param      array $columns Array of column names to validate.
472
	 * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
473
	 */
474
	protected function doValidate($columns = null)
475
	{
476
		if (!$this->alreadyInValidation) {
477
			$this->alreadyInValidation = true;
478
			$retval = null;
479
 
480
			$failureMap = array();
481
 
482
 
483
			if (($retval = MoviePeer::doValidate($this, $columns)) !== true) {
484
				$failureMap = array_merge($failureMap, $retval);
485
			}
486
 
487
 
488
				if ($this->collMovieI18ns !== null) {
489
					foreach ($this->collMovieI18ns as $referrerFK) {
490
						if (!$referrerFK->validate($columns)) {
491
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
492
						}
493
					}
494
				}
495
 
496
 
497
			$this->alreadyInValidation = false;
498
		}
499
 
500
		return (!empty($failureMap) ? $failureMap : true);
501
	}
502
 
503
	/**
504
	 * Retrieves a field from the object by name passed in as a string.
505
	 *
506
	 * @param      string $name name
507
	 * @param      string $type The type of fieldname the $name is of:
508
	 *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
509
	 *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
510
	 * @return     mixed Value of field.
511
	 */
512
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
513
	{
514
		$pos = MoviePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
515
		$field = $this->getByPosition($pos);
516
		return $field;
517
	}
518
 
519
	/**
520
	 * Retrieves a field from the object by Position as specified in the xml schema.
521
	 * Zero-based.
522
	 *
523
	 * @param      int $pos position in xml schema
524
	 * @return     mixed Value of field at $pos
525
	 */
526
	public function getByPosition($pos)
527
	{
528
		switch($pos) {
529
			case 0:
530
				return $this->getId();
531
				break;
532
			case 1:
533
				return $this->getDirector();
534
				break;
535
			default:
536
				return null;
537
				break;
538
		} // switch()
539
	}
540
 
541
	/**
542
	 * Exports the object as an array.
543
	 *
544
	 * You can specify the key type of the array by passing one of the class
545
	 * type constants.
546
	 *
547
	 * @param      string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
548
	 *                        BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
549
	 * @param      boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns.  Defaults to TRUE.
550
	 * @return     an associative array containing the field names (as keys) and field values
551
	 */
552
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
553
	{
554
		$keys = MoviePeer::getFieldNames($keyType);
555
		$result = array(
556
			$keys[0] => $this->getId(),
557
			$keys[1] => $this->getDirector(),
558
		);
559
		return $result;
560
	}
561
 
562
	/**
563
	 * Sets a field from the object by name passed in as a string.
564
	 *
565
	 * @param      string $name peer name
566
	 * @param      mixed $value field value
567
	 * @param      string $type The type of fieldname the $name is of:
568
	 *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
569
	 *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
570
	 * @return     void
571
	 */
572
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
573
	{
574
		$pos = MoviePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
575
		return $this->setByPosition($pos, $value);
576
	}
577
 
578
	/**
579
	 * Sets a field from the object by Position as specified in the xml schema.
580
	 * Zero-based.
581
	 *
582
	 * @param      int $pos position in xml schema
583
	 * @param      mixed $value field value
584
	 * @return     void
585
	 */
586
	public function setByPosition($pos, $value)
587
	{
588
		switch($pos) {
589
			case 0:
590
				$this->setId($value);
591
				break;
592
			case 1:
593
				$this->setDirector($value);
594
				break;
595
		} // switch()
596
	}
597
 
598
	/**
599
	 * Populates the object using an array.
600
	 *
601
	 * This is particularly useful when populating an object from one of the
602
	 * request arrays (e.g. $_POST).  This method goes through the column
603
	 * names, checking to see whether a matching key exists in populated
604
	 * array. If so the setByName() method is called for that column.
605
	 *
606
	 * You can specify the key type of the array by additionally passing one
607
	 * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
608
	 * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
609
	 * The default key type is the column's phpname (e.g. 'AuthorId')
610
	 *
611
	 * @param      array  $arr     An array to populate the object from.
612
	 * @param      string $keyType The type of keys the array uses.
613
	 * @return     void
614
	 */
615
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
616
	{
617
		$keys = MoviePeer::getFieldNames($keyType);
618
 
619
		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
620
		if (array_key_exists($keys[1], $arr)) $this->setDirector($arr[$keys[1]]);
621
	}
622
 
623
	/**
624
	 * Build a Criteria object containing the values of all modified columns in this object.
625
	 *
626
	 * @return     Criteria The Criteria object containing all modified values.
627
	 */
628
	public function buildCriteria()
629
	{
630
		$criteria = new Criteria(MoviePeer::DATABASE_NAME);
631
 
632
		if ($this->isColumnModified(MoviePeer::ID)) $criteria->add(MoviePeer::ID, $this->id);
633
		if ($this->isColumnModified(MoviePeer::DIRECTOR)) $criteria->add(MoviePeer::DIRECTOR, $this->director);
634
 
635
		return $criteria;
636
	}
637
 
638
	/**
639
	 * Builds a Criteria object containing the primary key for this object.
640
	 *
641
	 * Unlike buildCriteria() this method includes the primary key values regardless
642
	 * of whether or not they have been modified.
643
	 *
644
	 * @return     Criteria The Criteria object containing value(s) for primary key(s).
645
	 */
646
	public function buildPkeyCriteria()
647
	{
648
		$criteria = new Criteria(MoviePeer::DATABASE_NAME);
649
 
650
		$criteria->add(MoviePeer::ID, $this->id);
651
 
652
		return $criteria;
653
	}
654
 
655
	/**
656
	 * Returns the primary key for this object (row).
657
	 * @return     int
658
	 */
659
	public function getPrimaryKey()
660
	{
661
		return $this->getId();
662
	}
663
 
664
	/**
665
	 * Generic method to set the primary key (id column).
666
	 *
667
	 * @param      int $key Primary key.
668
	 * @return     void
669
	 */
670
	public function setPrimaryKey($key)
671
	{
672
		$this->setId($key);
673
	}
674
 
675
	/**
676
	 * Sets contents of passed object to values from current object.
677
	 *
678
	 * If desired, this method can also make copies of all associated (fkey referrers)
679
	 * objects.
680
	 *
681
	 * @param      object $copyObj An object of Movie (or compatible) type.
682
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
683
	 * @throws     PropelException
684
	 */
685
	public function copyInto($copyObj, $deepCopy = false)
686
	{
687
 
688
		$copyObj->setDirector($this->director);
689
 
690
 
691
		if ($deepCopy) {
692
			// important: temporarily setNew(false) because this affects the behavior of
693
			// the getter/setter methods for fkey referrer objects.
694
			$copyObj->setNew(false);
695
 
696
			foreach ($this->getMovieI18ns() as $relObj) {
697
				if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
698
					$copyObj->addMovieI18n($relObj->copy($deepCopy));
699
				}
700
			}
701
 
702
		} // if ($deepCopy)
703
 
704
 
705
		$copyObj->setNew(true);
706
 
707
		$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
708
 
709
	}
710
 
711
	/**
712
	 * Makes a copy of this object that will be inserted as a new row in table when saved.
713
	 * It creates a new object filling in the simple attributes, but skipping any primary
714
	 * keys that are defined for the table.
715
	 *
716
	 * If desired, this method can also make copies of all associated (fkey referrers)
717
	 * objects.
718
	 *
719
	 * @param      boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
720
	 * @return     Movie Clone of current object.
721
	 * @throws     PropelException
722
	 */
723
	public function copy($deepCopy = false)
724
	{
725
		// we use get_class(), because this might be a subclass
726
		$clazz = get_class($this);
727
		$copyObj = new $clazz();
728
		$this->copyInto($copyObj, $deepCopy);
729
		return $copyObj;
730
	}
731
 
732
	/**
733
	 * Returns a peer instance associated with this om.
734
	 *
735
	 * Since Peer classes are not to have any instance attributes, this method returns the
736
	 * same instance for all member of this class. The method could therefore
737
	 * be static, but this would prevent one from overriding the behavior.
738
	 *
739
	 * @return     MoviePeer
740
	 */
741
	public function getPeer()
742
	{
743
		if (self::$peer === null) {
744
			self::$peer = new MoviePeer();
745
		}
746
		return self::$peer;
747
	}
748
 
749
	/**
750
	 * Clears out the collMovieI18ns collection (array).
751
	 *
752
	 * This does not modify the database; however, it will remove any associated objects, causing
753
	 * them to be refetched by subsequent calls to accessor method.
754
	 *
755
	 * @return     void
756
	 * @see        addMovieI18ns()
757
	 */
758
	public function clearMovieI18ns()
759
	{
760
		$this->collMovieI18ns = null; // important to set this to NULL since that means it is uninitialized
761
	}
762
 
763
	/**
764
	 * Initializes the collMovieI18ns collection (array).
765
	 *
766
	 * By default this just sets the collMovieI18ns collection to an empty array (like clearcollMovieI18ns());
767
	 * however, you may wish to override this method in your stub class to provide setting appropriate
768
	 * to your application -- for example, setting the initial array to the values stored in database.
769
	 *
770
	 * @return     void
771
	 */
772
	public function initMovieI18ns()
773
	{
774
		$this->collMovieI18ns = array();
775
	}
776
 
777
	/**
778
	 * Gets an array of MovieI18n objects which contain a foreign key that references this object.
779
	 *
780
	 * If this collection has already been initialized with an identical Criteria, it returns the collection.
781
	 * Otherwise if this Movie has previously been saved, it will retrieve
782
	 * related MovieI18ns from storage. If this Movie is new, it will return
783
	 * an empty collection or the current collection, the criteria is ignored on a new object.
784
	 *
785
	 * @param      PropelPDO $con
786
	 * @param      Criteria $criteria
787
	 * @return     array MovieI18n[]
788
	 * @throws     PropelException
789
	 */
790
	public function getMovieI18ns($criteria = null, PropelPDO $con = null)
791
	{
792
		if ($criteria === null) {
793
			$criteria = new Criteria(MoviePeer::DATABASE_NAME);
794
		}
795
		elseif ($criteria instanceof Criteria)
796
		{
797
			$criteria = clone $criteria;
798
		}
799
 
800
		if ($this->collMovieI18ns === null) {
801
			if ($this->isNew()) {
802
			   $this->collMovieI18ns = array();
803
			} else {
804
 
805
				$criteria->add(MovieI18nPeer::ID, $this->id);
806
 
807
				MovieI18nPeer::addSelectColumns($criteria);
808
				$this->collMovieI18ns = MovieI18nPeer::doSelect($criteria, $con);
809
			}
810
		} else {
811
			// criteria has no effect for a new object
812
			if (!$this->isNew()) {
813
				// the following code is to determine if a new query is
814
				// called for.  If the criteria is the same as the last
815
				// one, just return the collection.
816
 
817
 
818
				$criteria->add(MovieI18nPeer::ID, $this->id);
819
 
820
				MovieI18nPeer::addSelectColumns($criteria);
821
				if (!isset($this->lastMovieI18nCriteria) || !$this->lastMovieI18nCriteria->equals($criteria)) {
822
					$this->collMovieI18ns = MovieI18nPeer::doSelect($criteria, $con);
823
				}
824
			}
825
		}
826
		$this->lastMovieI18nCriteria = $criteria;
827
		return $this->collMovieI18ns;
828
	}
829
 
830
	/**
831
	 * Returns the number of related MovieI18n objects.
832
	 *
833
	 * @param      Criteria $criteria
834
	 * @param      boolean $distinct
835
	 * @param      PropelPDO $con
836
	 * @return     int Count of related MovieI18n objects.
837
	 * @throws     PropelException
838
	 */
839
	public function countMovieI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
840
	{
841
		if ($criteria === null) {
842
			$criteria = new Criteria(MoviePeer::DATABASE_NAME);
843
		} else {
844
			$criteria = clone $criteria;
845
		}
846
 
847
		if ($distinct) {
848
			$criteria->setDistinct();
849
		}
850
 
851
		$count = null;
852
 
853
		if ($this->collMovieI18ns === null) {
854
			if ($this->isNew()) {
855
				$count = 0;
856
			} else {
857
 
858
				$criteria->add(MovieI18nPeer::ID, $this->id);
859
 
860
				$count = MovieI18nPeer::doCount($criteria, false, $con);
861
			}
862
		} else {
863
			// criteria has no effect for a new object
864
			if (!$this->isNew()) {
865
				// the following code is to determine if a new query is
866
				// called for.  If the criteria is the same as the last
867
				// one, just return count of the collection.
868
 
869
 
870
				$criteria->add(MovieI18nPeer::ID, $this->id);
871
 
872
				if (!isset($this->lastMovieI18nCriteria) || !$this->lastMovieI18nCriteria->equals($criteria)) {
873
					$count = MovieI18nPeer::doCount($criteria, false, $con);
874
				} else {
875
					$count = count($this->collMovieI18ns);
876
				}
877
			} else {
878
				$count = count($this->collMovieI18ns);
879
			}
880
		}
881
		return $count;
882
	}
883
 
884
	/**
885
	 * Method called to associate a MovieI18n object to this object
886
	 * through the MovieI18n foreign key attribute.
887
	 *
888
	 * @param      MovieI18n $l MovieI18n
889
	 * @return     void
890
	 * @throws     PropelException
891
	 */
892
	public function addMovieI18n(MovieI18n $l)
893
	{
894
		if ($this->collMovieI18ns === null) {
895
			$this->initMovieI18ns();
896
		}
897
		if (!in_array($l, $this->collMovieI18ns, true)) { // only add it if the **same** object is not already associated
898
			array_push($this->collMovieI18ns, $l);
899
			$l->setMovie($this);
900
		}
901
	}
902
 
903
	/**
904
	 * Resets all collections of referencing foreign keys.
905
	 *
906
	 * This method is a user-space workaround for PHP's inability to garbage collect objects
907
	 * with circular references.  This is currently necessary when using Propel in certain
908
	 * daemon or large-volumne/high-memory operations.
909
	 *
910
	 * @param      boolean $deep Whether to also clear the references on all associated objects.
911
	 */
912
	public function clearAllReferences($deep = false)
913
	{
914
		if ($deep) {
915
			if ($this->collMovieI18ns) {
916
				foreach ((array) $this->collMovieI18ns as $o) {
917
					$o->clearAllReferences($deep);
918
				}
919
			}
920
		} // if ($deep)
921
 
922
		$this->collMovieI18ns = null;
923
	}
924
 
925
	// symfony_behaviors behavior
926
 
927
	/**
928
	 * Calls methods defined via {@link sfMixer}.
929
	 */
930
	public function __call($method, $arguments)
931
	{
932
	  if (!$callable = sfMixer::getCallable('BaseMovie:'.$method))
933
	  {
934
	    throw new sfException(sprintf('Call to undefined method BaseMovie::%s', $method));
935
	  }
936
 
937
	  array_unshift($arguments, $this);
938
 
939
	  return call_user_func_array($callable, $arguments);
940
	}
941
 
942
	// symfony_i18n behavior
943
 
944
	/**
945
	 * Returns the culture.
946
	 *
947
	 * @return string The culture
948
	 */
949
	public function getCulture()
950
	{
951
	  return $this->culture;
952
	}
953
 
954
	/**
955
	 * Sets the culture.
956
	 *
957
	 * @param string  The culture to set
958
	 *
959
	 * @return Movie
960
	 */
961
	public function setCulture($culture)
962
	{
963
	  $this->culture = $culture;
964
	  return $this;
965
	}
966
 
967
	/**
968
	 * Returns the "title" value from the current {@link MovieI18n}.
969
	 */
970
	public function getTitle($culture = null)
971
	{
972
	  return $this->getCurrentMovieI18n($culture)->getTitle();
973
	}
974
 
975
	/**
976
	 * Sets the "title" value of the current {@link MovieI18n}.
977
	 *
978
	 * @return Movie
979
	 */
980
	public function setTitle($value, $culture = null)
981
	{
982
	  $this->getCurrentMovieI18n($culture)->setTitle($value);
983
	  return $this;
984
	}
985
 
986
	/**
987
	 * Returns the current translation.
988
	 *
989
	 * @return MovieI18n
990
	 */
991
	public function getCurrentMovieI18n($culture = null)
992
	{
993
	  if (null === $culture)
994
	  {
995
	    $culture = null === $this->culture ? sfPropel::getDefaultCulture() : $this->culture;
996
	  }
997
 
998
	  if (!isset($this->current_i18n[$culture]))
999
	  {
1000
	    $object = $this->isNew() ? null : MovieI18nPeer::retrieveByPK($this->getPrimaryKey(), $culture);
1001
	    if ($object)
1002
	    {
1003
	      $this->setMovieI18nForCulture($object, $culture);
1004
	    }
1005
	    else
1006
	    {
1007
	      $this->setMovieI18nForCulture(new MovieI18n(), $culture);
1008
	      $this->current_i18n[$culture]->setCulture($culture);
1009
	    }
1010
	  }
1011
 
1012
	  return $this->current_i18n[$culture];
1013
	}
1014
 
1015
	/**
1016
	 * Sets the translation object for a culture.
1017
	 */
1018
	public function setMovieI18nForCulture(MovieI18n $object, $culture)
1019
	{
1020
	  $this->current_i18n[$culture] = $object;
1021
	  $this->addMovieI18n($object);
1022
	}
1023
 
1024
	/**
1025
	 * @see MovieI18n
1026
	 */
1027
	public function __toString()
1028
	{
1029
	  return (string) $this->getCurrentMovieI18n();
1030
	}
1031
 
1032
} // BaseMovie