BaseCcPerms.php 25 KB

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