BaseCcShowSchedule.php 26 KB

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