BaseCcShowHosts.php 26 KB

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