BaseCcBlockcriteria.php 27 KB

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