BaseCcBackup.php 27 KB

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