PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/model/om/BaseCpu.php

http://pumukit.googlecode.com/
PHP | 1743 lines | 861 code | 268 blank | 614 comment | 155 complexity | 50e580f22d76b07b4438bede37785f0f MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'cpu' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseCpu extends BaseObject implements Persistent {
  10. /**
  11. * The Peer class.
  12. * Instance provides a convenient way of calling static methods on a class
  13. * that calling code may not be able to identify.
  14. * @var CpuPeer
  15. */
  16. protected static $peer;
  17. /**
  18. * The value for the id field.
  19. * @var int
  20. */
  21. protected $id;
  22. /**
  23. * The value for the ip field.
  24. * @var string
  25. */
  26. protected $ip;
  27. /**
  28. * The value for the max field.
  29. * @var int
  30. */
  31. protected $max;
  32. /**
  33. * The value for the min field.
  34. * @var int
  35. */
  36. protected $min;
  37. /**
  38. * The value for the number field.
  39. * @var int
  40. */
  41. protected $number;
  42. /**
  43. * The value for the type field.
  44. * @var string
  45. */
  46. protected $type;
  47. /**
  48. * The value for the user field.
  49. * @var string
  50. */
  51. protected $user;
  52. /**
  53. * The value for the password field.
  54. * @var string
  55. */
  56. protected $password;
  57. /**
  58. * Collection to store aggregation of collLogTranscodings.
  59. * @var array
  60. */
  61. protected $collLogTranscodings;
  62. /**
  63. * The criteria used to select the current contents of collLogTranscodings.
  64. * @var Criteria
  65. */
  66. protected $lastLogTranscodingCriteria = null;
  67. /**
  68. * Collection to store aggregation of collTranscodings.
  69. * @var array
  70. */
  71. protected $collTranscodings;
  72. /**
  73. * The criteria used to select the current contents of collTranscodings.
  74. * @var Criteria
  75. */
  76. protected $lastTranscodingCriteria = null;
  77. /**
  78. * Collection to store aggregation of collCpuI18ns.
  79. * @var array
  80. */
  81. protected $collCpuI18ns;
  82. /**
  83. * The criteria used to select the current contents of collCpuI18ns.
  84. * @var Criteria
  85. */
  86. protected $lastCpuI18nCriteria = null;
  87. /**
  88. * Flag to prevent endless save loop, if this object is referenced
  89. * by another object which falls in this transaction.
  90. * @var boolean
  91. */
  92. protected $alreadyInSave = false;
  93. /**
  94. * Flag to prevent endless validation loop, if this object is referenced
  95. * by another object which falls in this transaction.
  96. * @var boolean
  97. */
  98. protected $alreadyInValidation = false;
  99. /**
  100. * The value for the culture field.
  101. * @var string
  102. */
  103. protected $culture;
  104. /**
  105. * Get the [id] column value.
  106. *
  107. * @return int
  108. */
  109. public function getId()
  110. {
  111. return $this->id;
  112. }
  113. /**
  114. * Get the [ip] column value.
  115. *
  116. * @return string
  117. */
  118. public function getIp()
  119. {
  120. return $this->ip;
  121. }
  122. /**
  123. * Get the [max] column value.
  124. *
  125. * @return int
  126. */
  127. public function getMax()
  128. {
  129. return $this->max;
  130. }
  131. /**
  132. * Get the [min] column value.
  133. *
  134. * @return int
  135. */
  136. public function getMin()
  137. {
  138. return $this->min;
  139. }
  140. /**
  141. * Get the [number] column value.
  142. *
  143. * @return int
  144. */
  145. public function getNumber()
  146. {
  147. return $this->number;
  148. }
  149. /**
  150. * Get the [type] column value.
  151. *
  152. * @return string
  153. */
  154. public function getType()
  155. {
  156. return $this->type;
  157. }
  158. /**
  159. * Get the [user] column value.
  160. *
  161. * @return string
  162. */
  163. public function getUser()
  164. {
  165. return $this->user;
  166. }
  167. /**
  168. * Get the [password] column value.
  169. *
  170. * @return string
  171. */
  172. public function getPassword()
  173. {
  174. return $this->password;
  175. }
  176. /**
  177. * Set the value of [id] column.
  178. *
  179. * @param int $v new value
  180. * @return void
  181. */
  182. public function setId($v)
  183. {
  184. // Since the native PHP type for this column is integer,
  185. // we will cast the input value to an int (if it is not).
  186. if ($v !== null && !is_int($v) && is_numeric($v)) {
  187. $v = (int) $v;
  188. }
  189. if ($this->id !== $v) {
  190. $this->id = $v;
  191. $this->modifiedColumns[] = CpuPeer::ID;
  192. }
  193. } // setId()
  194. /**
  195. * Set the value of [ip] column.
  196. *
  197. * @param string $v new value
  198. * @return void
  199. */
  200. public function setIp($v)
  201. {
  202. // Since the native PHP type for this column is string,
  203. // we will cast the input to a string (if it is not).
  204. if ($v !== null && !is_string($v)) {
  205. $v = (string) $v;
  206. }
  207. if ($this->ip !== $v) {
  208. $this->ip = $v;
  209. $this->modifiedColumns[] = CpuPeer::IP;
  210. }
  211. } // setIp()
  212. /**
  213. * Set the value of [max] column.
  214. *
  215. * @param int $v new value
  216. * @return void
  217. */
  218. public function setMax($v)
  219. {
  220. // Since the native PHP type for this column is integer,
  221. // we will cast the input value to an int (if it is not).
  222. if ($v !== null && !is_int($v) && is_numeric($v)) {
  223. $v = (int) $v;
  224. }
  225. if ($this->max !== $v) {
  226. $this->max = $v;
  227. $this->modifiedColumns[] = CpuPeer::MAX;
  228. }
  229. } // setMax()
  230. /**
  231. * Set the value of [min] column.
  232. *
  233. * @param int $v new value
  234. * @return void
  235. */
  236. public function setMin($v)
  237. {
  238. // Since the native PHP type for this column is integer,
  239. // we will cast the input value to an int (if it is not).
  240. if ($v !== null && !is_int($v) && is_numeric($v)) {
  241. $v = (int) $v;
  242. }
  243. if ($this->min !== $v) {
  244. $this->min = $v;
  245. $this->modifiedColumns[] = CpuPeer::MIN;
  246. }
  247. } // setMin()
  248. /**
  249. * Set the value of [number] column.
  250. *
  251. * @param int $v new value
  252. * @return void
  253. */
  254. public function setNumber($v)
  255. {
  256. // Since the native PHP type for this column is integer,
  257. // we will cast the input value to an int (if it is not).
  258. if ($v !== null && !is_int($v) && is_numeric($v)) {
  259. $v = (int) $v;
  260. }
  261. if ($this->number !== $v) {
  262. $this->number = $v;
  263. $this->modifiedColumns[] = CpuPeer::NUMBER;
  264. }
  265. } // setNumber()
  266. /**
  267. * Set the value of [type] column.
  268. *
  269. * @param string $v new value
  270. * @return void
  271. */
  272. public function setType($v)
  273. {
  274. // Since the native PHP type for this column is string,
  275. // we will cast the input to a string (if it is not).
  276. if ($v !== null && !is_string($v)) {
  277. $v = (string) $v;
  278. }
  279. if ($this->type !== $v) {
  280. $this->type = $v;
  281. $this->modifiedColumns[] = CpuPeer::TYPE;
  282. }
  283. } // setType()
  284. /**
  285. * Set the value of [user] column.
  286. *
  287. * @param string $v new value
  288. * @return void
  289. */
  290. public function setUser($v)
  291. {
  292. // Since the native PHP type for this column is string,
  293. // we will cast the input to a string (if it is not).
  294. if ($v !== null && !is_string($v)) {
  295. $v = (string) $v;
  296. }
  297. if ($this->user !== $v) {
  298. $this->user = $v;
  299. $this->modifiedColumns[] = CpuPeer::USER;
  300. }
  301. } // setUser()
  302. /**
  303. * Set the value of [password] column.
  304. *
  305. * @param string $v new value
  306. * @return void
  307. */
  308. public function setPassword($v)
  309. {
  310. // Since the native PHP type for this column is string,
  311. // we will cast the input to a string (if it is not).
  312. if ($v !== null && !is_string($v)) {
  313. $v = (string) $v;
  314. }
  315. if ($this->password !== $v) {
  316. $this->password = $v;
  317. $this->modifiedColumns[] = CpuPeer::PASSWORD;
  318. }
  319. } // setPassword()
  320. /**
  321. * Hydrates (populates) the object variables with values from the database resultset.
  322. *
  323. * An offset (1-based "start column") is specified so that objects can be hydrated
  324. * with a subset of the columns in the resultset rows. This is needed, for example,
  325. * for results of JOIN queries where the resultset row includes columns from two or
  326. * more tables.
  327. *
  328. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  329. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  330. * @return int next starting column
  331. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  332. */
  333. public function hydrate(ResultSet $rs, $startcol = 1)
  334. {
  335. try {
  336. $this->id = $rs->getInt($startcol + 0);
  337. $this->ip = $rs->getString($startcol + 1);
  338. $this->max = $rs->getInt($startcol + 2);
  339. $this->min = $rs->getInt($startcol + 3);
  340. $this->number = $rs->getInt($startcol + 4);
  341. $this->type = $rs->getString($startcol + 5);
  342. $this->user = $rs->getString($startcol + 6);
  343. $this->password = $rs->getString($startcol + 7);
  344. $this->resetModified();
  345. $this->setNew(false);
  346. $this->setCulture(sfContext::getInstance()->getUser()->getCulture());
  347. // FIXME - using NUM_COLUMNS may be clearer.
  348. return $startcol + 8; // 8 = CpuPeer::NUM_COLUMNS - CpuPeer::NUM_LAZY_LOAD_COLUMNS).
  349. } catch (Exception $e) {
  350. throw new PropelException("Error populating Cpu object", $e);
  351. }
  352. }
  353. /**
  354. * Removes this object from datastore and sets delete attribute.
  355. *
  356. * @param Connection $con
  357. * @return void
  358. * @throws PropelException
  359. * @see BaseObject::setDeleted()
  360. * @see BaseObject::isDeleted()
  361. */
  362. public function delete($con = null)
  363. {
  364. foreach (sfMixer::getCallables('BaseCpu:delete:pre') as $callable)
  365. {
  366. $ret = call_user_func($callable, $this, $con);
  367. if ($ret)
  368. {
  369. return;
  370. }
  371. }
  372. if ($this->isDeleted()) {
  373. throw new PropelException("This object has already been deleted.");
  374. }
  375. if ($con === null) {
  376. $con = Propel::getConnection(CpuPeer::DATABASE_NAME);
  377. }
  378. try {
  379. $con->begin();
  380. CpuPeer::doDelete($this, $con);
  381. $this->setDeleted(true);
  382. $con->commit();
  383. } catch (PropelException $e) {
  384. $con->rollback();
  385. throw $e;
  386. }
  387. foreach (sfMixer::getCallables('BaseCpu:delete:post') as $callable)
  388. {
  389. call_user_func($callable, $this, $con);
  390. }
  391. }
  392. /**
  393. * Stores the object in the database. If the object is new,
  394. * it inserts it; otherwise an update is performed. This method
  395. * wraps the doSave() worker method in a transaction.
  396. *
  397. * @param Connection $con
  398. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  399. * @throws PropelException
  400. * @see doSave()
  401. */
  402. public function save($con = null)
  403. {
  404. foreach (sfMixer::getCallables('BaseCpu:save:pre') as $callable)
  405. {
  406. $affectedRows = call_user_func($callable, $this, $con);
  407. if (is_int($affectedRows))
  408. {
  409. return $affectedRows;
  410. }
  411. }
  412. if ($this->isDeleted()) {
  413. throw new PropelException("You cannot save an object that has been deleted.");
  414. }
  415. if ($con === null) {
  416. $con = Propel::getConnection(CpuPeer::DATABASE_NAME);
  417. }
  418. try {
  419. $con->begin();
  420. $affectedRows = $this->doSave($con);
  421. $con->commit();
  422. foreach (sfMixer::getCallables('BaseCpu:save:post') as $callable)
  423. {
  424. call_user_func($callable, $this, $con, $affectedRows);
  425. }
  426. return $affectedRows;
  427. } catch (PropelException $e) {
  428. $con->rollback();
  429. throw $e;
  430. }
  431. }
  432. /**
  433. * Stores the object in the database.
  434. *
  435. * If the object is new, it inserts it; otherwise an update is performed.
  436. * All related objects are also updated in this method.
  437. *
  438. * @param Connection $con
  439. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  440. * @throws PropelException
  441. * @see save()
  442. */
  443. protected function doSave($con)
  444. {
  445. $affectedRows = 0; // initialize var to track total num of affected rows
  446. if (!$this->alreadyInSave) {
  447. $this->alreadyInSave = true;
  448. // If this object has been modified, then save it to the database.
  449. if ($this->isModified()) {
  450. if ($this->isNew()) {
  451. $pk = CpuPeer::doInsert($this, $con);
  452. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  453. // should always be true here (even though technically
  454. // BasePeer::doInsert() can insert multiple rows).
  455. $this->setId($pk); //[IMV] update autoincrement primary key
  456. $this->setNew(false);
  457. } else {
  458. $affectedRows += CpuPeer::doUpdate($this, $con);
  459. }
  460. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  461. }
  462. if ($this->collLogTranscodings !== null) {
  463. foreach($this->collLogTranscodings as $referrerFK) {
  464. if (!$referrerFK->isDeleted()) {
  465. $affectedRows += $referrerFK->save($con);
  466. }
  467. }
  468. }
  469. if ($this->collTranscodings !== null) {
  470. foreach($this->collTranscodings as $referrerFK) {
  471. if (!$referrerFK->isDeleted()) {
  472. $affectedRows += $referrerFK->save($con);
  473. }
  474. }
  475. }
  476. if ($this->collCpuI18ns !== null) {
  477. foreach($this->collCpuI18ns as $referrerFK) {
  478. if (!$referrerFK->isDeleted()) {
  479. $affectedRows += $referrerFK->save($con);
  480. }
  481. }
  482. }
  483. $this->alreadyInSave = false;
  484. }
  485. return $affectedRows;
  486. } // doSave()
  487. /**
  488. * Array of ValidationFailed objects.
  489. * @var array ValidationFailed[]
  490. */
  491. protected $validationFailures = array();
  492. /**
  493. * Gets any ValidationFailed objects that resulted from last call to validate().
  494. *
  495. *
  496. * @return array ValidationFailed[]
  497. * @see validate()
  498. */
  499. public function getValidationFailures()
  500. {
  501. return $this->validationFailures;
  502. }
  503. /**
  504. * Validates the objects modified field values and all objects related to this table.
  505. *
  506. * If $columns is either a column name or an array of column names
  507. * only those columns are validated.
  508. *
  509. * @param mixed $columns Column name or an array of column names.
  510. * @return boolean Whether all columns pass validation.
  511. * @see doValidate()
  512. * @see getValidationFailures()
  513. */
  514. public function validate($columns = null)
  515. {
  516. $res = $this->doValidate($columns);
  517. if ($res === true) {
  518. $this->validationFailures = array();
  519. return true;
  520. } else {
  521. $this->validationFailures = $res;
  522. return false;
  523. }
  524. }
  525. /**
  526. * This function performs the validation work for complex object models.
  527. *
  528. * In addition to checking the current object, all related objects will
  529. * also be validated. If all pass then <code>true</code> is returned; otherwise
  530. * an aggreagated array of ValidationFailed objects will be returned.
  531. *
  532. * @param array $columns Array of column names to validate.
  533. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  534. */
  535. protected function doValidate($columns = null)
  536. {
  537. if (!$this->alreadyInValidation) {
  538. $this->alreadyInValidation = true;
  539. $retval = null;
  540. $failureMap = array();
  541. if (($retval = CpuPeer::doValidate($this, $columns)) !== true) {
  542. $failureMap = array_merge($failureMap, $retval);
  543. }
  544. if ($this->collLogTranscodings !== null) {
  545. foreach($this->collLogTranscodings as $referrerFK) {
  546. if (!$referrerFK->validate($columns)) {
  547. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  548. }
  549. }
  550. }
  551. if ($this->collTranscodings !== null) {
  552. foreach($this->collTranscodings as $referrerFK) {
  553. if (!$referrerFK->validate($columns)) {
  554. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  555. }
  556. }
  557. }
  558. if ($this->collCpuI18ns !== null) {
  559. foreach($this->collCpuI18ns as $referrerFK) {
  560. if (!$referrerFK->validate($columns)) {
  561. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  562. }
  563. }
  564. }
  565. $this->alreadyInValidation = false;
  566. }
  567. return (!empty($failureMap) ? $failureMap : true);
  568. }
  569. /**
  570. * Retrieves a field from the object by name passed in as a string.
  571. *
  572. * @param string $name name
  573. * @param string $type The type of fieldname the $name is of:
  574. * one of the class type constants TYPE_PHPNAME,
  575. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  576. * @return mixed Value of field.
  577. */
  578. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  579. {
  580. $pos = CpuPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  581. return $this->getByPosition($pos);
  582. }
  583. /**
  584. * Retrieves a field from the object by Position as specified in the xml schema.
  585. * Zero-based.
  586. *
  587. * @param int $pos position in xml schema
  588. * @return mixed Value of field at $pos
  589. */
  590. public function getByPosition($pos)
  591. {
  592. switch($pos) {
  593. case 0:
  594. return $this->getId();
  595. break;
  596. case 1:
  597. return $this->getIp();
  598. break;
  599. case 2:
  600. return $this->getMax();
  601. break;
  602. case 3:
  603. return $this->getMin();
  604. break;
  605. case 4:
  606. return $this->getNumber();
  607. break;
  608. case 5:
  609. return $this->getType();
  610. break;
  611. case 6:
  612. return $this->getUser();
  613. break;
  614. case 7:
  615. return $this->getPassword();
  616. break;
  617. default:
  618. return null;
  619. break;
  620. } // switch()
  621. }
  622. /**
  623. * Exports the object as an array.
  624. *
  625. * You can specify the key type of the array by passing one of the class
  626. * type constants.
  627. *
  628. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  629. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  630. * @return an associative array containing the field names (as keys) and field values
  631. */
  632. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  633. {
  634. $keys = CpuPeer::getFieldNames($keyType);
  635. $result = array(
  636. $keys[0] => $this->getId(),
  637. $keys[1] => $this->getIp(),
  638. $keys[2] => $this->getMax(),
  639. $keys[3] => $this->getMin(),
  640. $keys[4] => $this->getNumber(),
  641. $keys[5] => $this->getType(),
  642. $keys[6] => $this->getUser(),
  643. $keys[7] => $this->getPassword(),
  644. );
  645. return $result;
  646. }
  647. /**
  648. * Sets a field from the object by name passed in as a string.
  649. *
  650. * @param string $name peer name
  651. * @param mixed $value field value
  652. * @param string $type The type of fieldname the $name is of:
  653. * one of the class type constants TYPE_PHPNAME,
  654. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  655. * @return void
  656. */
  657. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  658. {
  659. $pos = CpuPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  660. return $this->setByPosition($pos, $value);
  661. }
  662. /**
  663. * Sets a field from the object by Position as specified in the xml schema.
  664. * Zero-based.
  665. *
  666. * @param int $pos position in xml schema
  667. * @param mixed $value field value
  668. * @return void
  669. */
  670. public function setByPosition($pos, $value)
  671. {
  672. switch($pos) {
  673. case 0:
  674. $this->setId($value);
  675. break;
  676. case 1:
  677. $this->setIp($value);
  678. break;
  679. case 2:
  680. $this->setMax($value);
  681. break;
  682. case 3:
  683. $this->setMin($value);
  684. break;
  685. case 4:
  686. $this->setNumber($value);
  687. break;
  688. case 5:
  689. $this->setType($value);
  690. break;
  691. case 6:
  692. $this->setUser($value);
  693. break;
  694. case 7:
  695. $this->setPassword($value);
  696. break;
  697. } // switch()
  698. }
  699. /**
  700. * Populates the object using an array.
  701. *
  702. * This is particularly useful when populating an object from one of the
  703. * request arrays (e.g. $_POST). This method goes through the column
  704. * names, checking to see whether a matching key exists in populated
  705. * array. If so the setByName() method is called for that column.
  706. *
  707. * You can specify the key type of the array by additionally passing one
  708. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  709. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  710. *
  711. * @param array $arr An array to populate the object from.
  712. * @param string $keyType The type of keys the array uses.
  713. * @return void
  714. */
  715. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  716. {
  717. $keys = CpuPeer::getFieldNames($keyType);
  718. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  719. if (array_key_exists($keys[1], $arr)) $this->setIp($arr[$keys[1]]);
  720. if (array_key_exists($keys[2], $arr)) $this->setMax($arr[$keys[2]]);
  721. if (array_key_exists($keys[3], $arr)) $this->setMin($arr[$keys[3]]);
  722. if (array_key_exists($keys[4], $arr)) $this->setNumber($arr[$keys[4]]);
  723. if (array_key_exists($keys[5], $arr)) $this->setType($arr[$keys[5]]);
  724. if (array_key_exists($keys[6], $arr)) $this->setUser($arr[$keys[6]]);
  725. if (array_key_exists($keys[7], $arr)) $this->setPassword($arr[$keys[7]]);
  726. }
  727. /**
  728. * Build a Criteria object containing the values of all modified columns in this object.
  729. *
  730. * @return Criteria The Criteria object containing all modified values.
  731. */
  732. public function buildCriteria()
  733. {
  734. $criteria = new Criteria(CpuPeer::DATABASE_NAME);
  735. if ($this->isColumnModified(CpuPeer::ID)) $criteria->add(CpuPeer::ID, $this->id);
  736. if ($this->isColumnModified(CpuPeer::IP)) $criteria->add(CpuPeer::IP, $this->ip);
  737. if ($this->isColumnModified(CpuPeer::MAX)) $criteria->add(CpuPeer::MAX, $this->max);
  738. if ($this->isColumnModified(CpuPeer::MIN)) $criteria->add(CpuPeer::MIN, $this->min);
  739. if ($this->isColumnModified(CpuPeer::NUMBER)) $criteria->add(CpuPeer::NUMBER, $this->number);
  740. if ($this->isColumnModified(CpuPeer::TYPE)) $criteria->add(CpuPeer::TYPE, $this->type);
  741. if ($this->isColumnModified(CpuPeer::USER)) $criteria->add(CpuPeer::USER, $this->user);
  742. if ($this->isColumnModified(CpuPeer::PASSWORD)) $criteria->add(CpuPeer::PASSWORD, $this->password);
  743. return $criteria;
  744. }
  745. /**
  746. * Builds a Criteria object containing the primary key for this object.
  747. *
  748. * Unlike buildCriteria() this method includes the primary key values regardless
  749. * of whether or not they have been modified.
  750. *
  751. * @return Criteria The Criteria object containing value(s) for primary key(s).
  752. */
  753. public function buildPkeyCriteria()
  754. {
  755. $criteria = new Criteria(CpuPeer::DATABASE_NAME);
  756. $criteria->add(CpuPeer::ID, $this->id);
  757. return $criteria;
  758. }
  759. /**
  760. * Returns the primary key for this object (row).
  761. * @return int
  762. */
  763. public function getPrimaryKey()
  764. {
  765. return $this->getId();
  766. }
  767. /**
  768. * Generic method to set the primary key (id column).
  769. *
  770. * @param int $key Primary key.
  771. * @return void
  772. */
  773. public function setPrimaryKey($key)
  774. {
  775. $this->setId($key);
  776. }
  777. /**
  778. * Sets contents of passed object to values from current object.
  779. *
  780. * If desired, this method can also make copies of all associated (fkey referrers)
  781. * objects.
  782. *
  783. * @param object $copyObj An object of Cpu (or compatible) type.
  784. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  785. * @throws PropelException
  786. */
  787. public function copyInto($copyObj, $deepCopy = false)
  788. {
  789. $copyObj->setIp($this->ip);
  790. $copyObj->setMax($this->max);
  791. $copyObj->setMin($this->min);
  792. $copyObj->setNumber($this->number);
  793. $copyObj->setType($this->type);
  794. $copyObj->setUser($this->user);
  795. $copyObj->setPassword($this->password);
  796. if ($deepCopy) {
  797. // important: temporarily setNew(false) because this affects the behavior of
  798. // the getter/setter methods for fkey referrer objects.
  799. $copyObj->setNew(false);
  800. foreach($this->getLogTranscodings() as $relObj) {
  801. $copyObj->addLogTranscoding($relObj->copy($deepCopy));
  802. }
  803. foreach($this->getTranscodings() as $relObj) {
  804. $copyObj->addTranscoding($relObj->copy($deepCopy));
  805. }
  806. foreach($this->getCpuI18ns() as $relObj) {
  807. $copyObj->addCpuI18n($relObj->copy($deepCopy));
  808. }
  809. } // if ($deepCopy)
  810. $copyObj->setNew(true);
  811. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  812. }
  813. /**
  814. * Makes a copy of this object that will be inserted as a new row in table when saved.
  815. * It creates a new object filling in the simple attributes, but skipping any primary
  816. * keys that are defined for the table.
  817. *
  818. * If desired, this method can also make copies of all associated (fkey referrers)
  819. * objects.
  820. *
  821. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  822. * @return Cpu Clone of current object.
  823. * @throws PropelException
  824. */
  825. public function copy($deepCopy = false)
  826. {
  827. // we use get_class(), because this might be a subclass
  828. $clazz = get_class($this);
  829. $copyObj = new $clazz();
  830. $this->copyInto($copyObj, $deepCopy);
  831. return $copyObj;
  832. }
  833. /**
  834. * Returns a peer instance associated with this om.
  835. *
  836. * Since Peer classes are not to have any instance attributes, this method returns the
  837. * same instance for all member of this class. The method could therefore
  838. * be static, but this would prevent one from overriding the behavior.
  839. *
  840. * @return CpuPeer
  841. */
  842. public function getPeer()
  843. {
  844. if (self::$peer === null) {
  845. self::$peer = new CpuPeer();
  846. }
  847. return self::$peer;
  848. }
  849. /**
  850. * Temporary storage of collLogTranscodings to save a possible db hit in
  851. * the event objects are add to the collection, but the
  852. * complete collection is never requested.
  853. * @return void
  854. */
  855. public function initLogTranscodings()
  856. {
  857. if ($this->collLogTranscodings === null) {
  858. $this->collLogTranscodings = array();
  859. }
  860. }
  861. /**
  862. * If this collection has already been initialized with
  863. * an identical criteria, it returns the collection.
  864. * Otherwise if this Cpu has previously
  865. * been saved, it will retrieve related LogTranscodings from storage.
  866. * If this Cpu is new, it will return
  867. * an empty collection or the current collection, the criteria
  868. * is ignored on a new object.
  869. *
  870. * @param Connection $con
  871. * @param Criteria $criteria
  872. * @throws PropelException
  873. */
  874. public function getLogTranscodings($criteria = null, $con = null)
  875. {
  876. // include the Peer class
  877. include_once 'lib/model/om/BaseLogTranscodingPeer.php';
  878. if ($criteria === null) {
  879. $criteria = new Criteria();
  880. }
  881. elseif ($criteria instanceof Criteria)
  882. {
  883. $criteria = clone $criteria;
  884. }
  885. if ($this->collLogTranscodings === null) {
  886. if ($this->isNew()) {
  887. $this->collLogTranscodings = array();
  888. } else {
  889. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  890. LogTranscodingPeer::addSelectColumns($criteria);
  891. $this->collLogTranscodings = LogTranscodingPeer::doSelect($criteria, $con);
  892. }
  893. } else {
  894. // criteria has no effect for a new object
  895. if (!$this->isNew()) {
  896. // the following code is to determine if a new query is
  897. // called for. If the criteria is the same as the last
  898. // one, just return the collection.
  899. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  900. LogTranscodingPeer::addSelectColumns($criteria);
  901. if (!isset($this->lastLogTranscodingCriteria) || !$this->lastLogTranscodingCriteria->equals($criteria)) {
  902. $this->collLogTranscodings = LogTranscodingPeer::doSelect($criteria, $con);
  903. }
  904. }
  905. }
  906. $this->lastLogTranscodingCriteria = $criteria;
  907. return $this->collLogTranscodings;
  908. }
  909. /**
  910. * Returns the number of related LogTranscodings.
  911. *
  912. * @param Criteria $criteria
  913. * @param boolean $distinct
  914. * @param Connection $con
  915. * @throws PropelException
  916. */
  917. public function countLogTranscodings($criteria = null, $distinct = false, $con = null)
  918. {
  919. // include the Peer class
  920. include_once 'lib/model/om/BaseLogTranscodingPeer.php';
  921. if ($criteria === null) {
  922. $criteria = new Criteria();
  923. }
  924. elseif ($criteria instanceof Criteria)
  925. {
  926. $criteria = clone $criteria;
  927. }
  928. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  929. return LogTranscodingPeer::doCount($criteria, $distinct, $con);
  930. }
  931. /**
  932. * Method called to associate a LogTranscoding object to this object
  933. * through the LogTranscoding foreign key attribute
  934. *
  935. * @param LogTranscoding $l LogTranscoding
  936. * @return void
  937. * @throws PropelException
  938. */
  939. public function addLogTranscoding(LogTranscoding $l)
  940. {
  941. $this->collLogTranscodings[] = $l;
  942. $l->setCpu($this);
  943. }
  944. /**
  945. * If this collection has already been initialized with
  946. * an identical criteria, it returns the collection.
  947. * Otherwise if this Cpu is new, it will return
  948. * an empty collection; or if this Cpu has previously
  949. * been saved, it will retrieve related LogTranscodings from storage.
  950. *
  951. * This method is protected by default in order to keep the public
  952. * api reasonable. You can provide public methods for those you
  953. * actually need in Cpu.
  954. */
  955. public function getLogTranscodingsJoinMm($criteria = null, $con = null)
  956. {
  957. // include the Peer class
  958. include_once 'lib/model/om/BaseLogTranscodingPeer.php';
  959. if ($criteria === null) {
  960. $criteria = new Criteria();
  961. }
  962. elseif ($criteria instanceof Criteria)
  963. {
  964. $criteria = clone $criteria;
  965. }
  966. if ($this->collLogTranscodings === null) {
  967. if ($this->isNew()) {
  968. $this->collLogTranscodings = array();
  969. } else {
  970. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  971. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinMm($criteria, $con);
  972. }
  973. } else {
  974. // the following code is to determine if a new query is
  975. // called for. If the criteria is the same as the last
  976. // one, just return the collection.
  977. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  978. if (!isset($this->lastLogTranscodingCriteria) || !$this->lastLogTranscodingCriteria->equals($criteria)) {
  979. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinMm($criteria, $con);
  980. }
  981. }
  982. $this->lastLogTranscodingCriteria = $criteria;
  983. return $this->collLogTranscodings;
  984. }
  985. /**
  986. * If this collection has already been initialized with
  987. * an identical criteria, it returns the collection.
  988. * Otherwise if this Cpu is new, it will return
  989. * an empty collection; or if this Cpu has previously
  990. * been saved, it will retrieve related LogTranscodings from storage.
  991. *
  992. * This method is protected by default in order to keep the public
  993. * api reasonable. You can provide public methods for those you
  994. * actually need in Cpu.
  995. */
  996. public function getLogTranscodingsJoinLanguage($criteria = null, $con = null)
  997. {
  998. // include the Peer class
  999. include_once 'lib/model/om/BaseLogTranscodingPeer.php';
  1000. if ($criteria === null) {
  1001. $criteria = new Criteria();
  1002. }
  1003. elseif ($criteria instanceof Criteria)
  1004. {
  1005. $criteria = clone $criteria;
  1006. }
  1007. if ($this->collLogTranscodings === null) {
  1008. if ($this->isNew()) {
  1009. $this->collLogTranscodings = array();
  1010. } else {
  1011. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  1012. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinLanguage($criteria, $con);
  1013. }
  1014. } else {
  1015. // the following code is to determine if a new query is
  1016. // called for. If the criteria is the same as the last
  1017. // one, just return the collection.
  1018. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  1019. if (!isset($this->lastLogTranscodingCriteria) || !$this->lastLogTranscodingCriteria->equals($criteria)) {
  1020. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinLanguage($criteria, $con);
  1021. }
  1022. }
  1023. $this->lastLogTranscodingCriteria = $criteria;
  1024. return $this->collLogTranscodings;
  1025. }
  1026. /**
  1027. * If this collection has already been initialized with
  1028. * an identical criteria, it returns the collection.
  1029. * Otherwise if this Cpu is new, it will return
  1030. * an empty collection; or if this Cpu has previously
  1031. * been saved, it will retrieve related LogTranscodings from storage.
  1032. *
  1033. * This method is protected by default in order to keep the public
  1034. * api reasonable. You can provide public methods for those you
  1035. * actually need in Cpu.
  1036. */
  1037. public function getLogTranscodingsJoinPerfil($criteria = null, $con = null)
  1038. {
  1039. // include the Peer class
  1040. include_once 'lib/model/om/BaseLogTranscodingPeer.php';
  1041. if ($criteria === null) {
  1042. $criteria = new Criteria();
  1043. }
  1044. elseif ($criteria instanceof Criteria)
  1045. {
  1046. $criteria = clone $criteria;
  1047. }
  1048. if ($this->collLogTranscodings === null) {
  1049. if ($this->isNew()) {
  1050. $this->collLogTranscodings = array();
  1051. } else {
  1052. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  1053. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinPerfil($criteria, $con);
  1054. }
  1055. } else {
  1056. // the following code is to determine if a new query is
  1057. // called for. If the criteria is the same as the last
  1058. // one, just return the collection.
  1059. $criteria->add(LogTranscodingPeer::CPU_ID, $this->getId());
  1060. if (!isset($this->lastLogTranscodingCriteria) || !$this->lastLogTranscodingCriteria->equals($criteria)) {
  1061. $this->collLogTranscodings = LogTranscodingPeer::doSelectJoinPerfil($criteria, $con);
  1062. }
  1063. }
  1064. $this->lastLogTranscodingCriteria = $criteria;
  1065. return $this->collLogTranscodings;
  1066. }
  1067. /**
  1068. * Temporary storage of collTranscodings to save a possible db hit in
  1069. * the event objects are add to the collection, but the
  1070. * complete collection is never requested.
  1071. * @return void
  1072. */
  1073. public function initTranscodings()
  1074. {
  1075. if ($this->collTranscodings === null) {
  1076. $this->collTranscodings = array();
  1077. }
  1078. }
  1079. /**
  1080. * If this collection has already been initialized with
  1081. * an identical criteria, it returns the collection.
  1082. * Otherwise if this Cpu has previously
  1083. * been saved, it will retrieve related Transcodings from storage.
  1084. * If this Cpu is new, it will return
  1085. * an empty collection or the current collection, the criteria
  1086. * is ignored on a new object.
  1087. *
  1088. * @param Connection $con
  1089. * @param Criteria $criteria
  1090. * @throws PropelException
  1091. */
  1092. public function getTranscodings($criteria = null, $con = null)
  1093. {
  1094. // include the Peer class
  1095. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1096. if ($criteria === null) {
  1097. $criteria = new Criteria();
  1098. }
  1099. elseif ($criteria instanceof Criteria)
  1100. {
  1101. $criteria = clone $criteria;
  1102. }
  1103. if ($this->collTranscodings === null) {
  1104. if ($this->isNew()) {
  1105. $this->collTranscodings = array();
  1106. } else {
  1107. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1108. TranscodingPeer::addSelectColumns($criteria);
  1109. $this->collTranscodings = TranscodingPeer::doSelect($criteria, $con);
  1110. }
  1111. } else {
  1112. // criteria has no effect for a new object
  1113. if (!$this->isNew()) {
  1114. // the following code is to determine if a new query is
  1115. // called for. If the criteria is the same as the last
  1116. // one, just return the collection.
  1117. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1118. TranscodingPeer::addSelectColumns($criteria);
  1119. if (!isset($this->lastTranscodingCriteria) || !$this->lastTranscodingCriteria->equals($criteria)) {
  1120. $this->collTranscodings = TranscodingPeer::doSelect($criteria, $con);
  1121. }
  1122. }
  1123. }
  1124. $this->lastTranscodingCriteria = $criteria;
  1125. return $this->collTranscodings;
  1126. }
  1127. /**
  1128. * Returns the number of related Transcodings.
  1129. *
  1130. * @param Criteria $criteria
  1131. * @param boolean $distinct
  1132. * @param Connection $con
  1133. * @throws PropelException
  1134. */
  1135. public function countTranscodings($criteria = null, $distinct = false, $con = null)
  1136. {
  1137. // include the Peer class
  1138. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1139. if ($criteria === null) {
  1140. $criteria = new Criteria();
  1141. }
  1142. elseif ($criteria instanceof Criteria)
  1143. {
  1144. $criteria = clone $criteria;
  1145. }
  1146. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1147. return TranscodingPeer::doCount($criteria, $distinct, $con);
  1148. }
  1149. /**
  1150. * Method called to associate a Transcoding object to this object
  1151. * through the Transcoding foreign key attribute
  1152. *
  1153. * @param Transcoding $l Transcoding
  1154. * @return void
  1155. * @throws PropelException
  1156. */
  1157. public function addTranscoding(Transcoding $l)
  1158. {
  1159. $this->collTranscodings[] = $l;
  1160. $l->setCpu($this);
  1161. }
  1162. /**
  1163. * If this collection has already been initialized with
  1164. * an identical criteria, it returns the collection.
  1165. * Otherwise if this Cpu is new, it will return
  1166. * an empty collection; or if this Cpu has previously
  1167. * been saved, it will retrieve related Transcodings from storage.
  1168. *
  1169. * This method is protected by default in order to keep the public
  1170. * api reasonable. You can provide public methods for those you
  1171. * actually need in Cpu.
  1172. */
  1173. public function getTranscodingsJoinMm($criteria = null, $con = null)
  1174. {
  1175. // include the Peer class
  1176. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1177. if ($criteria === null) {
  1178. $criteria = new Criteria();
  1179. }
  1180. elseif ($criteria instanceof Criteria)
  1181. {
  1182. $criteria = clone $criteria;
  1183. }
  1184. if ($this->collTranscodings === null) {
  1185. if ($this->isNew()) {
  1186. $this->collTranscodings = array();
  1187. } else {
  1188. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1189. $this->collTranscodings = TranscodingPeer::doSelectJoinMm($criteria, $con);
  1190. }
  1191. } else {
  1192. // the following code is to determine if a new query is
  1193. // called for. If the criteria is the same as the last
  1194. // one, just return the collection.
  1195. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1196. if (!isset($this->lastTranscodingCriteria) || !$this->lastTranscodingCriteria->equals($criteria)) {
  1197. $this->collTranscodings = TranscodingPeer::doSelectJoinMm($criteria, $con);
  1198. }
  1199. }
  1200. $this->lastTranscodingCriteria = $criteria;
  1201. return $this->collTranscodings;
  1202. }
  1203. /**
  1204. * If this collection has already been initialized with
  1205. * an identical criteria, it returns the collection.
  1206. * Otherwise if this Cpu is new, it will return
  1207. * an empty collection; or if this Cpu has previously
  1208. * been saved, it will retrieve related Transcodings from storage.
  1209. *
  1210. * This method is protected by default in order to keep the public
  1211. * api reasonable. You can provide public methods for those you
  1212. * actually need in Cpu.
  1213. */
  1214. public function getTranscodingsJoinLanguage($criteria = null, $con = null)
  1215. {
  1216. // include the Peer class
  1217. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1218. if ($criteria === null) {
  1219. $criteria = new Criteria();
  1220. }
  1221. elseif ($criteria instanceof Criteria)
  1222. {
  1223. $criteria = clone $criteria;
  1224. }
  1225. if ($this->collTranscodings === null) {
  1226. if ($this->isNew()) {
  1227. $this->collTranscodings = array();
  1228. } else {
  1229. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1230. $this->collTranscodings = TranscodingPeer::doSelectJoinLanguage($criteria, $con);
  1231. }
  1232. } else {
  1233. // the following code is to determine if a new query is
  1234. // called for. If the criteria is the same as the last
  1235. // one, just return the collection.
  1236. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1237. if (!isset($this->lastTranscodingCriteria) || !$this->lastTranscodingCriteria->equals($criteria)) {
  1238. $this->collTranscodings = TranscodingPeer::doSelectJoinLanguage($criteria, $con);
  1239. }
  1240. }
  1241. $this->lastTranscodingCriteria = $criteria;
  1242. return $this->collTranscodings;
  1243. }
  1244. /**
  1245. * If this collection has already been initialized with
  1246. * an identical criteria, it returns the collection.
  1247. * Otherwise if this Cpu is new, it will return
  1248. * an empty collection; or if this Cpu has previously
  1249. * been saved, it will retrieve related Transcodings from storage.
  1250. *
  1251. * This method is protected by default in order to keep the public
  1252. * api reasonable. You can provide public methods for those you
  1253. * actually need in Cpu.
  1254. */
  1255. public function getTranscodingsJoinPerfil($criteria = null, $con = null)
  1256. {
  1257. // include the Peer class
  1258. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1259. if ($criteria === null) {
  1260. $criteria = new Criteria();
  1261. }
  1262. elseif ($criteria instanceof Criteria)
  1263. {
  1264. $criteria = clone $criteria;
  1265. }
  1266. if ($this->collTranscodings === null) {
  1267. if ($this->isNew()) {
  1268. $this->collTranscodings = array();
  1269. } else {
  1270. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1271. $this->collTranscodings = TranscodingPeer::doSelectJoinPerfil($criteria, $con);
  1272. }
  1273. } else {
  1274. // the following code is to determine if a new query is
  1275. // called for. If the criteria is the same as the last
  1276. // one, just return the collection.
  1277. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1278. if (!isset($this->lastTranscodingCriteria) || !$this->lastTranscodingCriteria->equals($criteria)) {
  1279. $this->collTranscodings = TranscodingPeer::doSelectJoinPerfil($criteria, $con);
  1280. }
  1281. }
  1282. $this->lastTranscodingCriteria = $criteria;
  1283. return $this->collTranscodings;
  1284. }
  1285. /**
  1286. * If this collection has already been initialized with
  1287. * an identical criteria, it returns the collection.
  1288. * Otherwise if this Cpu has previously
  1289. * been saved, it will retrieve related Transcodings from storage.
  1290. * If this Cpu is new, it will return
  1291. * an empty collection or the current collection, the criteria
  1292. * is ignored on a new object.
  1293. *
  1294. * @param Connection $con
  1295. * @param Criteria $criteria
  1296. * @throws PropelException
  1297. */
  1298. public function getTranscodingsWithI18n($criteria = null, $con = null)
  1299. {
  1300. // include the Peer class
  1301. include_once 'lib/model/om/BaseTranscodingPeer.php';
  1302. if ($criteria === null) {
  1303. $criteria = new Criteria();
  1304. }
  1305. elseif ($criteria instanceof Criteria)
  1306. {
  1307. $criteria = clone $criteria;
  1308. }
  1309. if ($this->collTranscodings === null) {
  1310. if ($this->isNew()) {
  1311. $this->collTranscodings = array();
  1312. } else {
  1313. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1314. $this->collTranscodings = TranscodingPeer::doSelectWithI18n($criteria, $this->getCulture(), $con);
  1315. }
  1316. } else {
  1317. // criteria has no effect for a new object
  1318. if (!$this->isNew()) {
  1319. // the following code is to determine if a new query is
  1320. // called for. If the criteria is the same as the last
  1321. // one, just return the collection.
  1322. $criteria->add(TranscodingPeer::CPU_ID, $this->getId());
  1323. if (!isset($this->lastTranscodingCriteria) || !$this->lastTranscodingCriteria->equals($criteria)) {
  1324. $this->collTranscodings = TranscodingPeer::doSelectWithI18n($criteria, $this->getCulture(), $con);
  1325. }
  1326. }
  1327. }
  1328. $this->lastTranscodingCriteria = $criteria;
  1329. return $this->collTranscodings;
  1330. }
  1331. /**
  1332. * Temporary storage of collCpuI18ns to save a possible db hit in
  1333. * the event objects are add to the collection, but the
  1334. * complete collection is never requested.
  1335. * @return void
  1336. */
  1337. public function initCpuI18ns()
  1338. {
  1339. if ($this->collCpuI18ns === null) {
  1340. $this->collCpuI18ns = array();
  1341. }
  1342. }
  1343. /**
  1344. * If this collection has already been initialized with
  1345. * an identical criteria, it returns the collection.
  1346. * Otherwise if this Cpu has previously
  1347. * been saved, it will retrieve related CpuI18ns from storage.
  1348. * If this Cpu is new, it will return
  1349. * an empty collection or the current collection, the criteria
  1350. * is ignored on a new object.
  1351. *
  1352. * @param Connection $con
  1353. * @param Criteria $criteria
  1354. * @throws PropelException
  1355. */
  1356. public function getCpuI18ns($criteria = null, $con = null)
  1357. {
  1358. // include the Peer class
  1359. include_once 'lib/model/om/BaseCpuI18nPeer.php';
  1360. if ($criteria === null) {
  1361. $criteria = new Criteria();
  1362. }
  1363. elseif ($criteria instanceof Criteria)
  1364. {
  1365. $criteria = clone $criteria;
  1366. }
  1367. if ($this->collCpuI18ns === null) {
  1368. if ($this->isNew()) {
  1369. $this->collCpuI18ns = array();
  1370. } else {
  1371. $criteria->add(CpuI18nPeer::ID, $this->getId());
  1372. CpuI18nPeer::addSelectColumns($criteria);
  1373. $this->collCpuI18ns = CpuI18nPeer::doSelect($criteria, $con);
  1374. }
  1375. } else {
  1376. // criteria has no effect for a new object
  1377. if (!$this->isNew()) {
  1378. // the following code is to determine if a new query is
  1379. // called for. If the criteria is the same as the last
  1380. // one, just return the collection.
  1381. $criteria->add(CpuI18nPeer::ID, $this->getId());
  1382. CpuI18nPeer::addSelectColumns($criteria);
  1383. if (!isset($this->lastCpuI18nCriteria) || !$this->lastCpuI18nCriteria->equals($criteria)) {
  1384. $this->collCpuI18ns = CpuI18nPeer::doSelect($criteria, $con);
  1385. }
  1386. }
  1387. }
  1388. $this->lastCpuI18nCriteria = $criteria;
  1389. return $this->collCpuI18ns;
  1390. }
  1391. /**
  1392. * Returns the number of related CpuI18ns.
  1393. *
  1394. * @param Criteria $criteria
  1395. * @param boolean $distinct
  1396. * @param Connection $con
  1397. * @throws PropelException
  1398. */
  1399. public function countCpuI18ns($criteria = null, $distinct = false, $con = null)
  1400. {
  1401. // include the Peer class
  1402. include_once 'lib/model/om/BaseCpuI18nPeer.php';
  1403. if ($criteria === null) {
  1404. $criteria = new Criteria();
  1405. }
  1406. elseif ($criteria instanceof Criteria)
  1407. {
  1408. $criteria = clone $criteria;
  1409. }
  1410. $criteria->add(CpuI18nPeer::ID, $this->getId());
  1411. return CpuI18nPeer::doCount($criteria, $distinct, $con);
  1412. }
  1413. /**
  1414. * Method called to associate a CpuI18n object to this object
  1415. * through the CpuI18n foreign key attribute
  1416. *
  1417. * @param CpuI18n $l CpuI18n
  1418. * @return void
  1419. * @throws PropelException
  1420. */
  1421. public function addCpuI18n(CpuI18n $l)
  1422. {
  1423. $this->collCpuI18ns[] = $l;
  1424. $l->setCpu($this);
  1425. }
  1426. public function getCulture()
  1427. {
  1428. return $this->culture;
  1429. }
  1430. public function setCulture($culture)
  1431. {
  1432. $this->culture = $culture;
  1433. }
  1434. public function getDescription()
  1435. {
  1436. $obj = $this->getCurrentCpuI18n();
  1437. return ($obj ? $obj->getDescription() : null);
  1438. }
  1439. public function setDescription($value)
  1440. {
  1441. $this->getCurrentCpuI18n()->setDescription($value);
  1442. }
  1443. protected $current_i18n = array();
  1444. public function getCurrentCpuI18n()
  1445. {
  1446. if (!isset($this->current_i18n[$this->culture]))
  1447. {
  1448. $obj = CpuI18nPeer::retrieveByPK($this->getId(), $this->culture);
  1449. if ($obj)
  1450. {
  1451. $this->setCpuI18nForCulture($obj, $this->culture);
  1452. }
  1453. else
  1454. {
  1455. $this->setCpuI18nForCulture(new CpuI18n(), $this->culture);
  1456. $this->current_i18n[$this->culture]->setCulture($this->culture);
  1457. }
  1458. }
  1459. return $this->current_i18n[$this->culture];
  1460. }
  1461. public function setCpuI18nForCulture($object, $culture)
  1462. {
  1463. $this->current_i18n[$culture] = $object;
  1464. $this->addCpuI18n($object);
  1465. }
  1466. public function __call($method, $arguments)
  1467. {
  1468. if (!$callable = sfMixer::getCallable('BaseCpu:'.$method))
  1469. {
  1470. throw new sfException(sprintf('Call to undefined method BaseCpu::%s', $method));
  1471. }
  1472. array_unshift($arguments, $this);
  1473. return call_user_func_array($callable, $arguments);
  1474. }
  1475. } // BaseCpu