PageRenderTime 55ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/package/app/app/alpha/lib/model/om/BaseSchedulerStatus.php

https://bitbucket.org/pandaos/kaltura
PHP | 1402 lines | 697 code | 176 blank | 529 comment | 114 complexity | 7483b3ac505f42ac3149710bebd0709a MD5 | raw file
Possible License(s): AGPL-3.0, GPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-2.0, LGPL-3.0, JSON, MPL-2.0-no-copyleft-exception, Apache-2.0
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'scheduler_status' table.
  4. *
  5. *
  6. *
  7. * @package Core
  8. * @subpackage model.om
  9. */
  10. abstract class BaseSchedulerStatus extends BaseObject implements Persistent {
  11. /**
  12. * The Peer class.
  13. * Instance provides a convenient way of calling static methods on a class
  14. * that calling code may not be able to identify.
  15. * @var SchedulerStatusPeer
  16. */
  17. protected static $peer;
  18. /**
  19. * The value for the id field.
  20. * @var int
  21. */
  22. protected $id;
  23. /**
  24. * The value for the created_at field.
  25. * @var string
  26. */
  27. protected $created_at;
  28. /**
  29. * The value for the created_by field.
  30. * @var string
  31. */
  32. protected $created_by;
  33. /**
  34. * The value for the updated_at field.
  35. * @var string
  36. */
  37. protected $updated_at;
  38. /**
  39. * The value for the updated_by field.
  40. * @var string
  41. */
  42. protected $updated_by;
  43. /**
  44. * The value for the scheduler_id field.
  45. * @var int
  46. */
  47. protected $scheduler_id;
  48. /**
  49. * The value for the scheduler_configured_id field.
  50. * @var int
  51. */
  52. protected $scheduler_configured_id;
  53. /**
  54. * The value for the worker_id field.
  55. * @var int
  56. */
  57. protected $worker_id;
  58. /**
  59. * The value for the worker_configured_id field.
  60. * @var int
  61. */
  62. protected $worker_configured_id;
  63. /**
  64. * The value for the worker_type field.
  65. * @var int
  66. */
  67. protected $worker_type;
  68. /**
  69. * The value for the type field.
  70. * @var int
  71. */
  72. protected $type;
  73. /**
  74. * The value for the value field.
  75. * @var int
  76. */
  77. protected $value;
  78. /**
  79. * Flag to prevent endless save loop, if this object is referenced
  80. * by another object which falls in this transaction.
  81. * @var boolean
  82. */
  83. protected $alreadyInSave = false;
  84. /**
  85. * Flag to prevent endless validation loop, if this object is referenced
  86. * by another object which falls in this transaction.
  87. * @var boolean
  88. */
  89. protected $alreadyInValidation = false;
  90. /**
  91. * Store columns old values before the changes
  92. * @var array
  93. */
  94. protected $oldColumnsValues = array();
  95. /**
  96. * @return array
  97. */
  98. public function getColumnsOldValues()
  99. {
  100. return $this->oldColumnsValues;
  101. }
  102. /**
  103. * Get the [id] column value.
  104. *
  105. * @return int
  106. */
  107. public function getId()
  108. {
  109. return $this->id;
  110. }
  111. /**
  112. * Get the [optionally formatted] temporal [created_at] column value.
  113. *
  114. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  115. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  116. *
  117. * @param string $format The date/time format string (either date()-style or strftime()-style).
  118. * If format is NULL, then the raw unix timestamp integer will be returned.
  119. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  120. * @throws PropelException - if unable to parse/validate the date/time value.
  121. */
  122. public function getCreatedAt($format = 'Y-m-d H:i:s')
  123. {
  124. if ($this->created_at === null) {
  125. return null;
  126. }
  127. if ($this->created_at === '0000-00-00 00:00:00') {
  128. // while technically this is not a default value of NULL,
  129. // this seems to be closest in meaning.
  130. return null;
  131. } else {
  132. try {
  133. $dt = new DateTime($this->created_at);
  134. } catch (Exception $x) {
  135. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->created_at, true), $x);
  136. }
  137. }
  138. if ($format === null) {
  139. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  140. return (int) $dt->format('U');
  141. } elseif (strpos($format, '%') !== false) {
  142. return strftime($format, $dt->format('U'));
  143. } else {
  144. return $dt->format($format);
  145. }
  146. }
  147. /**
  148. * Get the [created_by] column value.
  149. *
  150. * @return string
  151. */
  152. public function getCreatedBy()
  153. {
  154. return $this->created_by;
  155. }
  156. /**
  157. * Get the [optionally formatted] temporal [updated_at] column value.
  158. *
  159. * This accessor only only work with unix epoch dates. Consider enabling the propel.useDateTimeClass
  160. * option in order to avoid converstions to integers (which are limited in the dates they can express).
  161. *
  162. * @param string $format The date/time format string (either date()-style or strftime()-style).
  163. * If format is NULL, then the raw unix timestamp integer will be returned.
  164. * @return mixed Formatted date/time value as string or (integer) unix timestamp (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00
  165. * @throws PropelException - if unable to parse/validate the date/time value.
  166. */
  167. public function getUpdatedAt($format = 'Y-m-d H:i:s')
  168. {
  169. if ($this->updated_at === null) {
  170. return null;
  171. }
  172. if ($this->updated_at === '0000-00-00 00:00:00') {
  173. // while technically this is not a default value of NULL,
  174. // this seems to be closest in meaning.
  175. return null;
  176. } else {
  177. try {
  178. $dt = new DateTime($this->updated_at);
  179. } catch (Exception $x) {
  180. throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->updated_at, true), $x);
  181. }
  182. }
  183. if ($format === null) {
  184. // We cast here to maintain BC in API; obviously we will lose data if we're dealing with pre-/post-epoch dates.
  185. return (int) $dt->format('U');
  186. } elseif (strpos($format, '%') !== false) {
  187. return strftime($format, $dt->format('U'));
  188. } else {
  189. return $dt->format($format);
  190. }
  191. }
  192. /**
  193. * Get the [updated_by] column value.
  194. *
  195. * @return string
  196. */
  197. public function getUpdatedBy()
  198. {
  199. return $this->updated_by;
  200. }
  201. /**
  202. * Get the [scheduler_id] column value.
  203. *
  204. * @return int
  205. */
  206. public function getSchedulerId()
  207. {
  208. return $this->scheduler_id;
  209. }
  210. /**
  211. * Get the [scheduler_configured_id] column value.
  212. *
  213. * @return int
  214. */
  215. public function getSchedulerConfiguredId()
  216. {
  217. return $this->scheduler_configured_id;
  218. }
  219. /**
  220. * Get the [worker_id] column value.
  221. *
  222. * @return int
  223. */
  224. public function getWorkerId()
  225. {
  226. return $this->worker_id;
  227. }
  228. /**
  229. * Get the [worker_configured_id] column value.
  230. *
  231. * @return int
  232. */
  233. public function getWorkerConfiguredId()
  234. {
  235. return $this->worker_configured_id;
  236. }
  237. /**
  238. * Get the [worker_type] column value.
  239. *
  240. * @return int
  241. */
  242. public function getWorkerType()
  243. {
  244. return $this->worker_type;
  245. }
  246. /**
  247. * Get the [type] column value.
  248. *
  249. * @return int
  250. */
  251. public function getType()
  252. {
  253. return $this->type;
  254. }
  255. /**
  256. * Get the [value] column value.
  257. *
  258. * @return int
  259. */
  260. public function getValue()
  261. {
  262. return $this->value;
  263. }
  264. /**
  265. * Set the value of [id] column.
  266. *
  267. * @param int $v new value
  268. * @return SchedulerStatus The current object (for fluent API support)
  269. */
  270. public function setId($v)
  271. {
  272. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::ID]))
  273. $this->oldColumnsValues[SchedulerStatusPeer::ID] = $this->id;
  274. if ($v !== null) {
  275. $v = (int) $v;
  276. }
  277. if ($this->id !== $v) {
  278. $this->id = $v;
  279. $this->modifiedColumns[] = SchedulerStatusPeer::ID;
  280. }
  281. return $this;
  282. } // setId()
  283. /**
  284. * Sets the value of [created_at] column to a normalized version of the date/time value specified.
  285. *
  286. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  287. * be treated as NULL for temporal objects.
  288. * @return SchedulerStatus The current object (for fluent API support)
  289. */
  290. public function setCreatedAt($v)
  291. {
  292. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  293. // -- which is unexpected, to say the least.
  294. if ($v === null || $v === '') {
  295. $dt = null;
  296. } elseif ($v instanceof DateTime) {
  297. $dt = $v;
  298. } else {
  299. // some string/numeric value passed; we normalize that so that we can
  300. // validate it.
  301. try {
  302. if (is_numeric($v)) { // if it's a unix timestamp
  303. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  304. // We have to explicitly specify and then change the time zone because of a
  305. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  306. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  307. } else {
  308. $dt = new DateTime($v);
  309. }
  310. } catch (Exception $x) {
  311. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  312. }
  313. }
  314. if ( $this->created_at !== null || $dt !== null ) {
  315. // (nested ifs are a little easier to read in this case)
  316. $currNorm = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  317. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  318. if ( ($currNorm !== $newNorm) // normalized values don't match
  319. )
  320. {
  321. $this->created_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  322. $this->modifiedColumns[] = SchedulerStatusPeer::CREATED_AT;
  323. }
  324. } // if either are not null
  325. return $this;
  326. } // setCreatedAt()
  327. /**
  328. * Set the value of [created_by] column.
  329. *
  330. * @param string $v new value
  331. * @return SchedulerStatus The current object (for fluent API support)
  332. */
  333. public function setCreatedBy($v)
  334. {
  335. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::CREATED_BY]))
  336. $this->oldColumnsValues[SchedulerStatusPeer::CREATED_BY] = $this->created_by;
  337. if ($v !== null) {
  338. $v = (string) $v;
  339. }
  340. if ($this->created_by !== $v) {
  341. $this->created_by = $v;
  342. $this->modifiedColumns[] = SchedulerStatusPeer::CREATED_BY;
  343. }
  344. return $this;
  345. } // setCreatedBy()
  346. /**
  347. * Sets the value of [updated_at] column to a normalized version of the date/time value specified.
  348. *
  349. * @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
  350. * be treated as NULL for temporal objects.
  351. * @return SchedulerStatus The current object (for fluent API support)
  352. */
  353. public function setUpdatedAt($v)
  354. {
  355. // we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
  356. // -- which is unexpected, to say the least.
  357. if ($v === null || $v === '') {
  358. $dt = null;
  359. } elseif ($v instanceof DateTime) {
  360. $dt = $v;
  361. } else {
  362. // some string/numeric value passed; we normalize that so that we can
  363. // validate it.
  364. try {
  365. if (is_numeric($v)) { // if it's a unix timestamp
  366. $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
  367. // We have to explicitly specify and then change the time zone because of a
  368. // DateTime bug: http://bugs.php.net/bug.php?id=43003
  369. $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
  370. } else {
  371. $dt = new DateTime($v);
  372. }
  373. } catch (Exception $x) {
  374. throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
  375. }
  376. }
  377. if ( $this->updated_at !== null || $dt !== null ) {
  378. // (nested ifs are a little easier to read in this case)
  379. $currNorm = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null;
  380. $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
  381. if ( ($currNorm !== $newNorm) // normalized values don't match
  382. )
  383. {
  384. $this->updated_at = ($dt ? $dt->format('Y-m-d H:i:s') : null);
  385. $this->modifiedColumns[] = SchedulerStatusPeer::UPDATED_AT;
  386. }
  387. } // if either are not null
  388. return $this;
  389. } // setUpdatedAt()
  390. /**
  391. * Set the value of [updated_by] column.
  392. *
  393. * @param string $v new value
  394. * @return SchedulerStatus The current object (for fluent API support)
  395. */
  396. public function setUpdatedBy($v)
  397. {
  398. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::UPDATED_BY]))
  399. $this->oldColumnsValues[SchedulerStatusPeer::UPDATED_BY] = $this->updated_by;
  400. if ($v !== null) {
  401. $v = (string) $v;
  402. }
  403. if ($this->updated_by !== $v) {
  404. $this->updated_by = $v;
  405. $this->modifiedColumns[] = SchedulerStatusPeer::UPDATED_BY;
  406. }
  407. return $this;
  408. } // setUpdatedBy()
  409. /**
  410. * Set the value of [scheduler_id] column.
  411. *
  412. * @param int $v new value
  413. * @return SchedulerStatus The current object (for fluent API support)
  414. */
  415. public function setSchedulerId($v)
  416. {
  417. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::SCHEDULER_ID]))
  418. $this->oldColumnsValues[SchedulerStatusPeer::SCHEDULER_ID] = $this->scheduler_id;
  419. if ($v !== null) {
  420. $v = (int) $v;
  421. }
  422. if ($this->scheduler_id !== $v) {
  423. $this->scheduler_id = $v;
  424. $this->modifiedColumns[] = SchedulerStatusPeer::SCHEDULER_ID;
  425. }
  426. return $this;
  427. } // setSchedulerId()
  428. /**
  429. * Set the value of [scheduler_configured_id] column.
  430. *
  431. * @param int $v new value
  432. * @return SchedulerStatus The current object (for fluent API support)
  433. */
  434. public function setSchedulerConfiguredId($v)
  435. {
  436. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::SCHEDULER_CONFIGURED_ID]))
  437. $this->oldColumnsValues[SchedulerStatusPeer::SCHEDULER_CONFIGURED_ID] = $this->scheduler_configured_id;
  438. if ($v !== null) {
  439. $v = (int) $v;
  440. }
  441. if ($this->scheduler_configured_id !== $v) {
  442. $this->scheduler_configured_id = $v;
  443. $this->modifiedColumns[] = SchedulerStatusPeer::SCHEDULER_CONFIGURED_ID;
  444. }
  445. return $this;
  446. } // setSchedulerConfiguredId()
  447. /**
  448. * Set the value of [worker_id] column.
  449. *
  450. * @param int $v new value
  451. * @return SchedulerStatus The current object (for fluent API support)
  452. */
  453. public function setWorkerId($v)
  454. {
  455. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::WORKER_ID]))
  456. $this->oldColumnsValues[SchedulerStatusPeer::WORKER_ID] = $this->worker_id;
  457. if ($v !== null) {
  458. $v = (int) $v;
  459. }
  460. if ($this->worker_id !== $v) {
  461. $this->worker_id = $v;
  462. $this->modifiedColumns[] = SchedulerStatusPeer::WORKER_ID;
  463. }
  464. return $this;
  465. } // setWorkerId()
  466. /**
  467. * Set the value of [worker_configured_id] column.
  468. *
  469. * @param int $v new value
  470. * @return SchedulerStatus The current object (for fluent API support)
  471. */
  472. public function setWorkerConfiguredId($v)
  473. {
  474. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::WORKER_CONFIGURED_ID]))
  475. $this->oldColumnsValues[SchedulerStatusPeer::WORKER_CONFIGURED_ID] = $this->worker_configured_id;
  476. if ($v !== null) {
  477. $v = (int) $v;
  478. }
  479. if ($this->worker_configured_id !== $v) {
  480. $this->worker_configured_id = $v;
  481. $this->modifiedColumns[] = SchedulerStatusPeer::WORKER_CONFIGURED_ID;
  482. }
  483. return $this;
  484. } // setWorkerConfiguredId()
  485. /**
  486. * Set the value of [worker_type] column.
  487. *
  488. * @param int $v new value
  489. * @return SchedulerStatus The current object (for fluent API support)
  490. */
  491. public function setWorkerType($v)
  492. {
  493. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::WORKER_TYPE]))
  494. $this->oldColumnsValues[SchedulerStatusPeer::WORKER_TYPE] = $this->worker_type;
  495. if ($v !== null) {
  496. $v = (int) $v;
  497. }
  498. if ($this->worker_type !== $v) {
  499. $this->worker_type = $v;
  500. $this->modifiedColumns[] = SchedulerStatusPeer::WORKER_TYPE;
  501. }
  502. return $this;
  503. } // setWorkerType()
  504. /**
  505. * Set the value of [type] column.
  506. *
  507. * @param int $v new value
  508. * @return SchedulerStatus The current object (for fluent API support)
  509. */
  510. public function setType($v)
  511. {
  512. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::TYPE]))
  513. $this->oldColumnsValues[SchedulerStatusPeer::TYPE] = $this->type;
  514. if ($v !== null) {
  515. $v = (int) $v;
  516. }
  517. if ($this->type !== $v) {
  518. $this->type = $v;
  519. $this->modifiedColumns[] = SchedulerStatusPeer::TYPE;
  520. }
  521. return $this;
  522. } // setType()
  523. /**
  524. * Set the value of [value] column.
  525. *
  526. * @param int $v new value
  527. * @return SchedulerStatus The current object (for fluent API support)
  528. */
  529. public function setValue($v)
  530. {
  531. if(!isset($this->oldColumnsValues[SchedulerStatusPeer::VALUE]))
  532. $this->oldColumnsValues[SchedulerStatusPeer::VALUE] = $this->value;
  533. if ($v !== null) {
  534. $v = (int) $v;
  535. }
  536. if ($this->value !== $v) {
  537. $this->value = $v;
  538. $this->modifiedColumns[] = SchedulerStatusPeer::VALUE;
  539. }
  540. return $this;
  541. } // setValue()
  542. /**
  543. * Indicates whether the columns in this object are only set to default values.
  544. *
  545. * This method can be used in conjunction with isModified() to indicate whether an object is both
  546. * modified _and_ has some values set which are non-default.
  547. *
  548. * @return boolean Whether the columns in this object are only been set with default values.
  549. */
  550. public function hasOnlyDefaultValues()
  551. {
  552. // otherwise, everything was equal, so return TRUE
  553. return true;
  554. } // hasOnlyDefaultValues()
  555. /**
  556. * Hydrates (populates) the object variables with values from the database resultset.
  557. *
  558. * An offset (0-based "start column") is specified so that objects can be hydrated
  559. * with a subset of the columns in the resultset rows. This is needed, for example,
  560. * for results of JOIN queries where the resultset row includes columns from two or
  561. * more tables.
  562. *
  563. * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
  564. * @param int $startcol 0-based offset column which indicates which restultset column to start with.
  565. * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
  566. * @return int next starting column
  567. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  568. */
  569. public function hydrate($row, $startcol = 0, $rehydrate = false)
  570. {
  571. try {
  572. $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
  573. $this->created_at = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
  574. $this->created_by = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
  575. $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
  576. $this->updated_by = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
  577. $this->scheduler_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
  578. $this->scheduler_configured_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
  579. $this->worker_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
  580. $this->worker_configured_id = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null;
  581. $this->worker_type = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
  582. $this->type = ($row[$startcol + 10] !== null) ? (int) $row[$startcol + 10] : null;
  583. $this->value = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null;
  584. $this->resetModified();
  585. $this->setNew(false);
  586. if ($rehydrate) {
  587. $this->ensureConsistency();
  588. }
  589. // FIXME - using NUM_COLUMNS may be clearer.
  590. return $startcol + 12; // 12 = SchedulerStatusPeer::NUM_COLUMNS - SchedulerStatusPeer::NUM_LAZY_LOAD_COLUMNS).
  591. } catch (Exception $e) {
  592. throw new PropelException("Error populating SchedulerStatus object", $e);
  593. }
  594. }
  595. /**
  596. * Checks and repairs the internal consistency of the object.
  597. *
  598. * This method is executed after an already-instantiated object is re-hydrated
  599. * from the database. It exists to check any foreign keys to make sure that
  600. * the objects related to the current object are correct based on foreign key.
  601. *
  602. * You can override this method in the stub class, but you should always invoke
  603. * the base method from the overridden method (i.e. parent::ensureConsistency()),
  604. * in case your model changes.
  605. *
  606. * @throws PropelException
  607. */
  608. public function ensureConsistency()
  609. {
  610. } // ensureConsistency
  611. /**
  612. * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  613. *
  614. * This will only work if the object has been saved and has a valid primary key set.
  615. *
  616. * @param boolean $deep (optional) Whether to also de-associated any related objects.
  617. * @param PropelPDO $con (optional) The PropelPDO connection to use.
  618. * @return void
  619. * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  620. */
  621. public function reload($deep = false, PropelPDO $con = null)
  622. {
  623. if ($this->isDeleted()) {
  624. throw new PropelException("Cannot reload a deleted object.");
  625. }
  626. if ($this->isNew()) {
  627. throw new PropelException("Cannot reload an unsaved object.");
  628. }
  629. if ($con === null) {
  630. $con = Propel::getConnection(SchedulerStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ);
  631. }
  632. // We don't need to alter the object instance pool; we're just modifying this instance
  633. // already in the pool.
  634. SchedulerStatusPeer::setUseCriteriaFilter(false);
  635. $stmt = SchedulerStatusPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
  636. SchedulerStatusPeer::setUseCriteriaFilter(true);
  637. $row = $stmt->fetch(PDO::FETCH_NUM);
  638. $stmt->closeCursor();
  639. if (!$row) {
  640. throw new PropelException('Cannot find matching row in the database to reload object values.');
  641. }
  642. $this->hydrate($row, 0, true); // rehydrate
  643. if ($deep) { // also de-associate any related objects?
  644. } // if (deep)
  645. }
  646. /**
  647. * Removes this object from datastore and sets delete attribute.
  648. *
  649. * @param PropelPDO $con
  650. * @return void
  651. * @throws PropelException
  652. * @see BaseObject::setDeleted()
  653. * @see BaseObject::isDeleted()
  654. */
  655. public function delete(PropelPDO $con = null)
  656. {
  657. if ($this->isDeleted()) {
  658. throw new PropelException("This object has already been deleted.");
  659. }
  660. if ($con === null) {
  661. $con = Propel::getConnection(SchedulerStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  662. }
  663. $con->beginTransaction();
  664. try {
  665. $ret = $this->preDelete($con);
  666. if ($ret) {
  667. SchedulerStatusPeer::doDelete($this, $con);
  668. $this->postDelete($con);
  669. $this->setDeleted(true);
  670. $con->commit();
  671. } else {
  672. $con->commit();
  673. }
  674. } catch (PropelException $e) {
  675. $con->rollBack();
  676. throw $e;
  677. }
  678. }
  679. /**
  680. * Persists this object to the database.
  681. *
  682. * If the object is new, it inserts it; otherwise an update is performed.
  683. * All modified related objects will also be persisted in the doSave()
  684. * method. This method wraps all precipitate database operations in a
  685. * single transaction.
  686. *
  687. * @param PropelPDO $con
  688. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  689. * @throws PropelException
  690. * @see doSave()
  691. */
  692. public function save(PropelPDO $con = null)
  693. {
  694. if ($this->isDeleted()) {
  695. throw new PropelException("You cannot save an object that has been deleted.");
  696. }
  697. if ($con === null) {
  698. $con = Propel::getConnection(SchedulerStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
  699. }
  700. $con->beginTransaction();
  701. $isInsert = $this->isNew();
  702. try {
  703. $ret = $this->preSave($con);
  704. if ($isInsert) {
  705. $ret = $ret && $this->preInsert($con);
  706. } else {
  707. $ret = $ret && $this->preUpdate($con);
  708. }
  709. if ($ret) {
  710. $affectedRows = $this->doSave($con);
  711. if ($isInsert) {
  712. $this->postInsert($con);
  713. } else {
  714. $this->postUpdate($con);
  715. }
  716. $this->postSave($con);
  717. SchedulerStatusPeer::addInstanceToPool($this);
  718. } else {
  719. $affectedRows = 0;
  720. }
  721. $con->commit();
  722. return $affectedRows;
  723. } catch (PropelException $e) {
  724. $con->rollBack();
  725. throw $e;
  726. }
  727. }
  728. /**
  729. * Performs the work of inserting or updating the row in the database.
  730. *
  731. * If the object is new, it inserts it; otherwise an update is performed.
  732. * All related objects are also updated in this method.
  733. *
  734. * @param PropelPDO $con
  735. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  736. * @throws PropelException
  737. * @see save()
  738. */
  739. protected function doSave(PropelPDO $con)
  740. {
  741. $affectedRows = 0; // initialize var to track total num of affected rows
  742. if (!$this->alreadyInSave) {
  743. $this->alreadyInSave = true;
  744. if ($this->isNew() ) {
  745. $this->modifiedColumns[] = SchedulerStatusPeer::ID;
  746. }
  747. // If this object has been modified, then save it to the database.
  748. if ($this->isModified()) {
  749. if ($this->isNew()) {
  750. $pk = SchedulerStatusPeer::doInsert($this, $con);
  751. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  752. // should always be true here (even though technically
  753. // BasePeer::doInsert() can insert multiple rows).
  754. $this->setId($pk); //[IMV] update autoincrement primary key
  755. $this->setNew(false);
  756. } else {
  757. $affectedRows += SchedulerStatusPeer::doUpdate($this, $con);
  758. }
  759. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  760. }
  761. $this->alreadyInSave = false;
  762. }
  763. return $affectedRows;
  764. } // doSave()
  765. /**
  766. * Override in order to use the query cache.
  767. * Cache invalidation keys are used to determine when cached queries are valid.
  768. * Before returning a query result from the cache, the time of the cached query
  769. * is compared to the time saved in the invalidation key.
  770. * A cached query will only be used if it's newer than the matching invalidation key.
  771. *
  772. * @return array Array of keys that will should be updated when this object is modified.
  773. */
  774. public function getCacheInvalidationKeys()
  775. {
  776. return array();
  777. }
  778. /**
  779. * Code to be run before persisting the object
  780. * @param PropelPDO $con
  781. * @return bloolean
  782. */
  783. public function preSave(PropelPDO $con = null)
  784. {
  785. return parent::preSave($con);
  786. }
  787. /**
  788. * Code to be run after persisting the object
  789. * @param PropelPDO $con
  790. */
  791. public function postSave(PropelPDO $con = null)
  792. {
  793. $this->oldColumnsValues = array();
  794. }
  795. /**
  796. * Code to be run before inserting to database
  797. * @param PropelPDO $con
  798. * @return boolean
  799. */
  800. public function preInsert(PropelPDO $con = null)
  801. {
  802. $this->setCreatedAt(time());
  803. $this->setUpdatedAt(time());
  804. return true;
  805. }
  806. /**
  807. * Code to be run after inserting to database
  808. * @param PropelPDO $con
  809. */
  810. public function postInsert(PropelPDO $con = null)
  811. {
  812. kQueryCache::invalidateQueryCache($this);
  813. }
  814. /**
  815. * Code to be run after updating the object in database
  816. * @param PropelPDO $con
  817. */
  818. public function postUpdate(PropelPDO $con = null)
  819. {
  820. if ($this->alreadyInSave)
  821. {
  822. return;
  823. }
  824. kQueryCache::invalidateQueryCache($this);
  825. }
  826. /**
  827. * Array of ValidationFailed objects.
  828. * @var array ValidationFailed[]
  829. */
  830. protected $validationFailures = array();
  831. /**
  832. * Gets any ValidationFailed objects that resulted from last call to validate().
  833. *
  834. *
  835. * @return array ValidationFailed[]
  836. * @see validate()
  837. */
  838. public function getValidationFailures()
  839. {
  840. return $this->validationFailures;
  841. }
  842. /**
  843. * Validates the objects modified field values and all objects related to this table.
  844. *
  845. * If $columns is either a column name or an array of column names
  846. * only those columns are validated.
  847. *
  848. * @param mixed $columns Column name or an array of column names.
  849. * @return boolean Whether all columns pass validation.
  850. * @see doValidate()
  851. * @see getValidationFailures()
  852. */
  853. public function validate($columns = null)
  854. {
  855. $res = $this->doValidate($columns);
  856. if ($res === true) {
  857. $this->validationFailures = array();
  858. return true;
  859. } else {
  860. $this->validationFailures = $res;
  861. return false;
  862. }
  863. }
  864. /**
  865. * This function performs the validation work for complex object models.
  866. *
  867. * In addition to checking the current object, all related objects will
  868. * also be validated. If all pass then <code>true</code> is returned; otherwise
  869. * an aggreagated array of ValidationFailed objects will be returned.
  870. *
  871. * @param array $columns Array of column names to validate.
  872. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  873. */
  874. protected function doValidate($columns = null)
  875. {
  876. if (!$this->alreadyInValidation) {
  877. $this->alreadyInValidation = true;
  878. $retval = null;
  879. $failureMap = array();
  880. if (($retval = SchedulerStatusPeer::doValidate($this, $columns)) !== true) {
  881. $failureMap = array_merge($failureMap, $retval);
  882. }
  883. $this->alreadyInValidation = false;
  884. }
  885. return (!empty($failureMap) ? $failureMap : true);
  886. }
  887. /**
  888. * Retrieves a field from the object by name passed in as a string.
  889. *
  890. * @param string $name name
  891. * @param string $type The type of fieldname the $name is of:
  892. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  893. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  894. * @return mixed Value of field.
  895. */
  896. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  897. {
  898. $pos = SchedulerStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  899. $field = $this->getByPosition($pos);
  900. return $field;
  901. }
  902. /**
  903. * Retrieves a field from the object by Position as specified in the xml schema.
  904. * Zero-based.
  905. *
  906. * @param int $pos position in xml schema
  907. * @return mixed Value of field at $pos
  908. */
  909. public function getByPosition($pos)
  910. {
  911. switch($pos) {
  912. case 0:
  913. return $this->getId();
  914. break;
  915. case 1:
  916. return $this->getCreatedAt();
  917. break;
  918. case 2:
  919. return $this->getCreatedBy();
  920. break;
  921. case 3:
  922. return $this->getUpdatedAt();
  923. break;
  924. case 4:
  925. return $this->getUpdatedBy();
  926. break;
  927. case 5:
  928. return $this->getSchedulerId();
  929. break;
  930. case 6:
  931. return $this->getSchedulerConfiguredId();
  932. break;
  933. case 7:
  934. return $this->getWorkerId();
  935. break;
  936. case 8:
  937. return $this->getWorkerConfiguredId();
  938. break;
  939. case 9:
  940. return $this->getWorkerType();
  941. break;
  942. case 10:
  943. return $this->getType();
  944. break;
  945. case 11:
  946. return $this->getValue();
  947. break;
  948. default:
  949. return null;
  950. break;
  951. } // switch()
  952. }
  953. /**
  954. * Exports the object as an array.
  955. *
  956. * You can specify the key type of the array by passing one of the class
  957. * type constants.
  958. *
  959. * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  960. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME.
  961. * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  962. * @return an associative array containing the field names (as keys) and field values
  963. */
  964. public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
  965. {
  966. $keys = SchedulerStatusPeer::getFieldNames($keyType);
  967. $result = array(
  968. $keys[0] => $this->getId(),
  969. $keys[1] => $this->getCreatedAt(),
  970. $keys[2] => $this->getCreatedBy(),
  971. $keys[3] => $this->getUpdatedAt(),
  972. $keys[4] => $this->getUpdatedBy(),
  973. $keys[5] => $this->getSchedulerId(),
  974. $keys[6] => $this->getSchedulerConfiguredId(),
  975. $keys[7] => $this->getWorkerId(),
  976. $keys[8] => $this->getWorkerConfiguredId(),
  977. $keys[9] => $this->getWorkerType(),
  978. $keys[10] => $this->getType(),
  979. $keys[11] => $this->getValue(),
  980. );
  981. return $result;
  982. }
  983. /**
  984. * Sets a field from the object by name passed in as a string.
  985. *
  986. * @param string $name peer name
  987. * @param mixed $value field value
  988. * @param string $type The type of fieldname the $name is of:
  989. * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  990. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  991. * @return void
  992. */
  993. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  994. {
  995. $pos = SchedulerStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  996. return $this->setByPosition($pos, $value);
  997. }
  998. /**
  999. * Sets a field from the object by Position as specified in the xml schema.
  1000. * Zero-based.
  1001. *
  1002. * @param int $pos position in xml schema
  1003. * @param mixed $value field value
  1004. * @return void
  1005. */
  1006. public function setByPosition($pos, $value)
  1007. {
  1008. switch($pos) {
  1009. case 0:
  1010. $this->setId($value);
  1011. break;
  1012. case 1:
  1013. $this->setCreatedAt($value);
  1014. break;
  1015. case 2:
  1016. $this->setCreatedBy($value);
  1017. break;
  1018. case 3:
  1019. $this->setUpdatedAt($value);
  1020. break;
  1021. case 4:
  1022. $this->setUpdatedBy($value);
  1023. break;
  1024. case 5:
  1025. $this->setSchedulerId($value);
  1026. break;
  1027. case 6:
  1028. $this->setSchedulerConfiguredId($value);
  1029. break;
  1030. case 7:
  1031. $this->setWorkerId($value);
  1032. break;
  1033. case 8:
  1034. $this->setWorkerConfiguredId($value);
  1035. break;
  1036. case 9:
  1037. $this->setWorkerType($value);
  1038. break;
  1039. case 10:
  1040. $this->setType($value);
  1041. break;
  1042. case 11:
  1043. $this->setValue($value);
  1044. break;
  1045. } // switch()
  1046. }
  1047. /**
  1048. * Populates the object using an array.
  1049. *
  1050. * This is particularly useful when populating an object from one of the
  1051. * request arrays (e.g. $_POST). This method goes through the column
  1052. * names, checking to see whether a matching key exists in populated
  1053. * array. If so the setByName() method is called for that column.
  1054. *
  1055. * You can specify the key type of the array by additionally passing one
  1056. * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  1057. * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  1058. * The default key type is the column's phpname (e.g. 'AuthorId')
  1059. *
  1060. * @param array $arr An array to populate the object from.
  1061. * @param string $keyType The type of keys the array uses.
  1062. * @return void
  1063. */
  1064. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  1065. {
  1066. $keys = SchedulerStatusPeer::getFieldNames($keyType);
  1067. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  1068. if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]);
  1069. if (array_key_exists($keys[2], $arr)) $this->setCreatedBy($arr[$keys[2]]);
  1070. if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]);
  1071. if (array_key_exists($keys[4], $arr)) $this->setUpdatedBy($arr[$keys[4]]);
  1072. if (array_key_exists($keys[5], $arr)) $this->setSchedulerId($arr[$keys[5]]);
  1073. if (array_key_exists($keys[6], $arr)) $this->setSchedulerConfiguredId($arr[$keys[6]]);
  1074. if (array_key_exists($keys[7], $arr)) $this->setWorkerId($arr[$keys[7]]);
  1075. if (array_key_exists($keys[8], $arr)) $this->setWorkerConfiguredId($arr[$keys[8]]);
  1076. if (array_key_exists($keys[9], $arr)) $this->setWorkerType($arr[$keys[9]]);
  1077. if (array_key_exists($keys[10], $arr)) $this->setType($arr[$keys[10]]);
  1078. if (array_key_exists($keys[11], $arr)) $this->setValue($arr[$keys[11]]);
  1079. }
  1080. /**
  1081. * Build a Criteria object containing the values of all modified columns in this object.
  1082. *
  1083. * @return Criteria The Criteria object containing all modified values.
  1084. */
  1085. public function buildCriteria()
  1086. {
  1087. $criteria = new Criteria(SchedulerStatusPeer::DATABASE_NAME);
  1088. if ($this->isColumnModified(SchedulerStatusPeer::ID)) $criteria->add(SchedulerStatusPeer::ID, $this->id);
  1089. if ($this->isColumnModified(SchedulerStatusPeer::CREATED_AT)) $criteria->add(SchedulerStatusPeer::CREATED_AT, $this->created_at);
  1090. if ($this->isColumnModified(SchedulerStatusPeer::CREATED_BY)) $criteria->add(SchedulerStatusPeer::CREATED_BY, $this->created_by);
  1091. if ($this->isColumnModified(SchedulerStatusPeer::UPDATED_AT)) $criteria->add(SchedulerStatusPeer::UPDATED_AT, $this->updated_at);
  1092. if ($this->isColumnModified(SchedulerStatusPeer::UPDATED_BY)) $criteria->add(SchedulerStatusPeer::UPDATED_BY, $this->updated_by);
  1093. if ($this->isColumnModified(SchedulerStatusPeer::SCHEDULER_ID)) $criteria->add(SchedulerStatusPeer::SCHEDULER_ID, $this->scheduler_id);
  1094. if ($this->isColumnModified(SchedulerStatusPeer::SCHEDULER_CONFIGURED_ID)) $criteria->add(SchedulerStatusPeer::SCHEDULER_CONFIGURED_ID, $this->scheduler_configured_id);
  1095. if ($this->isColumnModified(SchedulerStatusPeer::WORKER_ID)) $criteria->add(SchedulerStatusPeer::WORKER_ID, $this->worker_id);
  1096. if ($this->isColumnModified(SchedulerStatusPeer::WORKER_CONFIGURED_ID)) $criteria->add(SchedulerStatusPeer::WORKER_CONFIGURED_ID, $this->worker_configured_id);
  1097. if ($this->isColumnModified(SchedulerStatusPeer::WORKER_TYPE)) $criteria->add(SchedulerStatusPeer::WORKER_TYPE, $this->worker_type);
  1098. if ($this->isColumnModified(SchedulerStatusPeer::TYPE)) $criteria->add(SchedulerStatusPeer::TYPE, $this->type);
  1099. if ($this->isColumnModified(SchedulerStatusPeer::VALUE)) $criteria->add(SchedulerStatusPeer::VALUE, $this->value);
  1100. return $criteria;
  1101. }
  1102. /**
  1103. * Builds a Criteria object containing the primary key for this object.
  1104. *
  1105. * Unlike buildCriteria() this method includes the primary key values regardless
  1106. * of whether or not they have been modified.
  1107. *
  1108. * @return Criteria The Criteria object containing value(s) for primary key(s).
  1109. */
  1110. public function buildPkeyCriteria()
  1111. {
  1112. $criteria = new Criteria(SchedulerStatusPeer::DATABASE_NAME);
  1113. $criteria->add(SchedulerStatusPeer::ID, $this->id);
  1114. return $criteria;
  1115. }
  1116. /**
  1117. * Returns the primary key for this object (row).
  1118. * @return int
  1119. */
  1120. public function getPrimaryKey()
  1121. {
  1122. return $this->getId();
  1123. }
  1124. /**
  1125. * Generic method to set the primary key (id column).
  1126. *
  1127. * @param int $key Primary key.
  1128. * @return void
  1129. */
  1130. public function setPrimaryKey($key)
  1131. {
  1132. $this->setId($key);
  1133. }
  1134. /**
  1135. * Sets contents of passed object to values from current object.
  1136. *
  1137. * If desired, this method can also make copies of all associated (fkey referrers)
  1138. * objects.
  1139. *
  1140. * @param object $copyObj An object of SchedulerStatus (or compatible) type.
  1141. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1142. * @throws PropelException
  1143. */
  1144. public function copyInto($copyObj, $deepCopy = false)
  1145. {
  1146. $copyObj->setCreatedAt($this->created_at);
  1147. $copyObj->setCreatedBy($this->created_by);
  1148. $copyObj->setUpdatedAt($this->updated_at);
  1149. $copyObj->setUpdatedBy($this->updated_by);
  1150. $copyObj->setSchedulerId($this->scheduler_id);
  1151. $copyObj->setSchedulerConfiguredId($this->scheduler_configured_id);
  1152. $copyObj->setWorkerId($this->worker_id);
  1153. $copyObj->setWorkerConfiguredId($this->worker_configured_id);
  1154. $copyObj->setWorkerType($this->worker_type);
  1155. $copyObj->setType($this->type);
  1156. $copyObj->setValue($this->value);
  1157. $copyObj->setNew(true);
  1158. $copyObj->setId(NULL); // this is a auto-increment column, so set to default value
  1159. }
  1160. /**
  1161. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1162. * It creates a new object filling in the simple attributes, but skipping any primary
  1163. * keys that are defined for the table.
  1164. *
  1165. * If desired, this method can also make copies of all associated (fkey referrers)
  1166. * objects.
  1167. *
  1168. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1169. * @return SchedulerStatus Clone of current object.
  1170. * @throws PropelException
  1171. */
  1172. public function copy($deepCopy = false)
  1173. {
  1174. // we use get_class(), because this might be a subclass
  1175. $clazz = get_class($this);
  1176. $copyObj = new $clazz();
  1177. $this->copyInto($copyObj, $deepCopy);
  1178. $copyObj->setCopiedFrom($this);
  1179. return $copyObj;
  1180. }
  1181. /**
  1182. * Stores the source object that this object copied from
  1183. *
  1184. * @var SchedulerStatus Clone of current object.
  1185. */
  1186. protected $copiedFrom = null;
  1187. /**
  1188. * Stores the source object that this object copied from
  1189. *
  1190. * @param SchedulerStatus $copiedFrom Clone of current object.
  1191. */
  1192. public function setCopiedFrom(SchedulerStatus $copiedFrom)
  1193. {
  1194. $this->copiedFrom = $copiedFrom;
  1195. }
  1196. /**
  1197. * Returns a peer instance associated with this om.
  1198. *
  1199. * Since Peer classes are not to have any instance attributes, this method returns the
  1200. * same instance for all member of this class. The method could therefore
  1201. * be static, but this would prevent one from overriding the behavior.
  1202. *
  1203. * @return SchedulerStatusPeer
  1204. */
  1205. public function getPeer()
  1206. {
  1207. if (self::$peer === null) {
  1208. self::$peer = new SchedulerStatusPeer();
  1209. }
  1210. return self::$peer;
  1211. }
  1212. /**
  1213. * Resets all collections of referencing foreign keys.
  1214. *
  1215. * This method is a user-space workaround for PHP's inability to garbage collect objects
  1216. * with circular references. This is currently necessary when using Propel in certain
  1217. * daemon or large-volumne/high-memory operations.
  1218. *
  1219. * @param boolean $deep Whether to also clear the references on all associated objects.
  1220. */
  1221. public function clearAllReferences($deep = false)
  1222. {
  1223. if ($deep) {
  1224. } // if ($deep)
  1225. }
  1226. } // BaseSchedulerStatus