BaseCcSess.php 27 KB

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