BaseCcPlayoutHistoryTemplate.php 27 KB

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