BaseCcLiveLog.php 27 KB

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