BaseCcShowRebroadcast.php 28 KB

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