BaseCcSubjsToken.php 28 KB

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