BaseCcMusicDirs.php 31 KB

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