BaseCcMountName.php 26 KB

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