BaseCcPlayoutHistoryTemplateField.php 31 KB

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