BaseKataoNodeProduct.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'katao_node_product' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseKataoNodeProduct 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 KataoNodeProductPeer
  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 katao_node_id field.
  24. * @var int
  25. */
  26. protected $katao_node_id;
  27. /**
  28. * The value for the katao_period_id field.
  29. * @var int
  30. */
  31. protected $katao_period_id;
  32. /**
  33. * The value for the katao_product_id field.
  34. * @var int
  35. */
  36. protected $katao_product_id;
  37. /**
  38. * @var KataoNode
  39. */
  40. protected $aKataoNode;
  41. /**
  42. * @var KataoPeriod
  43. */
  44. protected $aKataoPeriod;
  45. /**
  46. * @var KataoProduct
  47. */
  48. protected $aKataoProduct;
  49. /**
  50. * Flag to prevent endless save loop, if this object is referenced
  51. * by another object which falls in this transaction.
  52. * @var boolean
  53. */
  54. protected $alreadyInSave = false;
  55. /**
  56. * Flag to prevent endless validation loop, if this object is referenced
  57. * by another object which falls in this transaction.
  58. * @var boolean
  59. */
  60. protected $alreadyInValidation = false;
  61. /**
  62. * Get the [id] column value.
  63. *
  64. * @return int
  65. */
  66. public function getId()
  67. {
  68. return $this->id;
  69. }
  70. /**
  71. * Get the [katao_node_id] column value.
  72. *
  73. * @return int
  74. */
  75. public function getKataoNodeId()
  76. {
  77. return $this->katao_node_id;
  78. }
  79. /**
  80. * Get the [katao_period_id] column value.
  81. *
  82. * @return int
  83. */
  84. public function getKataoPeriodId()
  85. {
  86. return $this->katao_period_id;
  87. }
  88. /**
  89. * Get the [katao_product_id] column value.
  90. *
  91. * @return int
  92. */
  93. public function getKataoProductId()
  94. {
  95. return $this->katao_product_id;
  96. }
  97. /**
  98. * Set the value of [id] column.
  99. *
  100. * @param int $v new value
  101. * @return void
  102. */
  103. public function setId($v)
  104. {
  105. // Since the native PHP type for this column is integer,
  106. // we will cast the input value to an int (if it is not).
  107. if ($v !== null && !is_int($v) && is_numeric($v)) {
  108. $v = (int) $v;
  109. }
  110. if ($this->id !== $v) {
  111. $this->id = $v;
  112. $this->modifiedColumns[] = KataoNodeProductPeer::ID;
  113. }
  114. } // setId()
  115. /**
  116. * Set the value of [katao_node_id] column.
  117. *
  118. * @param int $v new value
  119. * @return void
  120. */
  121. public function setKataoNodeId($v)
  122. {
  123. // Since the native PHP type for this column is integer,
  124. // we will cast the input value to an int (if it is not).
  125. if ($v !== null && !is_int($v) && is_numeric($v)) {
  126. $v = (int) $v;
  127. }
  128. if ($this->katao_node_id !== $v) {
  129. $this->katao_node_id = $v;
  130. $this->modifiedColumns[] = KataoNodeProductPeer::KATAO_NODE_ID;
  131. }
  132. if ($this->aKataoNode !== null && $this->aKataoNode->getId() !== $v) {
  133. $this->aKataoNode = null;
  134. }
  135. } // setKataoNodeId()
  136. /**
  137. * Set the value of [katao_period_id] column.
  138. *
  139. * @param int $v new value
  140. * @return void
  141. */
  142. public function setKataoPeriodId($v)
  143. {
  144. // Since the native PHP type for this column is integer,
  145. // we will cast the input value to an int (if it is not).
  146. if ($v !== null && !is_int($v) && is_numeric($v)) {
  147. $v = (int) $v;
  148. }
  149. if ($this->katao_period_id !== $v) {
  150. $this->katao_period_id = $v;
  151. $this->modifiedColumns[] = KataoNodeProductPeer::KATAO_PERIOD_ID;
  152. }
  153. if ($this->aKataoPeriod !== null && $this->aKataoPeriod->getId() !== $v) {
  154. $this->aKataoPeriod = null;
  155. }
  156. } // setKataoPeriodId()
  157. /**
  158. * Set the value of [katao_product_id] column.
  159. *
  160. * @param int $v new value
  161. * @return void
  162. */
  163. public function setKataoProductId($v)
  164. {
  165. // Since the native PHP type for this column is integer,
  166. // we will cast the input value to an int (if it is not).
  167. if ($v !== null && !is_int($v) && is_numeric($v)) {
  168. $v = (int) $v;
  169. }
  170. if ($this->katao_product_id !== $v) {
  171. $this->katao_product_id = $v;
  172. $this->modifiedColumns[] = KataoNodeProductPeer::KATAO_PRODUCT_ID;
  173. }
  174. if ($this->aKataoProduct !== null && $this->aKataoProduct->getId() !== $v) {
  175. $this->aKataoProduct = null;
  176. }
  177. } // setKataoProductId()
  178. /**
  179. * Hydrates (populates) the object variables with values from the database resultset.
  180. *
  181. * An offset (1-based "start column") is specified so that objects can be hydrated
  182. * with a subset of the columns in the resultset rows. This is needed, for example,
  183. * for results of JOIN queries where the resultset row includes columns from two or
  184. * more tables.
  185. *
  186. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  187. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  188. * @return int next starting column
  189. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  190. */
  191. public function hydrate(ResultSet $rs, $startcol = 1)
  192. {
  193. try {
  194. $this->id = $rs->getInt($startcol + 0);
  195. $this->katao_node_id = $rs->getInt($startcol + 1);
  196. $this->katao_period_id = $rs->getInt($startcol + 2);
  197. $this->katao_product_id = $rs->getInt($startcol + 3);
  198. $this->resetModified();
  199. $this->setNew(false);
  200. // FIXME - using NUM_COLUMNS may be clearer.
  201. return $startcol + 4; // 4 = KataoNodeProductPeer::NUM_COLUMNS - KataoNodeProductPeer::NUM_LAZY_LOAD_COLUMNS).
  202. } catch (Exception $e) {
  203. throw new PropelException("Error populating KataoNodeProduct object", $e);
  204. }
  205. }
  206. /**
  207. * Removes this object from datastore and sets delete attribute.
  208. *
  209. * @param Connection $con
  210. * @return void
  211. * @throws PropelException
  212. * @see BaseObject::setDeleted()
  213. * @see BaseObject::isDeleted()
  214. */
  215. public function delete($con = null)
  216. {
  217. foreach (sfMixer::getCallables('BaseKataoNodeProduct:delete:pre') as $callable)
  218. {
  219. $ret = call_user_func($callable, $this, $con);
  220. if ($ret)
  221. {
  222. return;
  223. }
  224. }
  225. if ($this->isDeleted()) {
  226. throw new PropelException("This object has already been deleted.");
  227. }
  228. if ($con === null) {
  229. $con = Propel::getConnection(KataoNodeProductPeer::DATABASE_NAME);
  230. }
  231. try {
  232. $con->begin();
  233. KataoNodeProductPeer::doDelete($this, $con);
  234. $this->setDeleted(true);
  235. $con->commit();
  236. } catch (PropelException $e) {
  237. $con->rollback();
  238. throw $e;
  239. }
  240. foreach (sfMixer::getCallables('BaseKataoNodeProduct:delete:post') as $callable)
  241. {
  242. call_user_func($callable, $this, $con);
  243. }
  244. }
  245. /**
  246. * Stores the object in the database. If the object is new,
  247. * it inserts it; otherwise an update is performed. This method
  248. * wraps the doSave() worker method in a transaction.
  249. *
  250. * @param Connection $con
  251. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  252. * @throws PropelException
  253. * @see doSave()
  254. */
  255. public function save($con = null)
  256. {
  257. foreach (sfMixer::getCallables('BaseKataoNodeProduct:save:pre') as $callable)
  258. {
  259. $affectedRows = call_user_func($callable, $this, $con);
  260. if (is_int($affectedRows))
  261. {
  262. return $affectedRows;
  263. }
  264. }
  265. if ($this->isDeleted()) {
  266. throw new PropelException("You cannot save an object that has been deleted.");
  267. }
  268. if ($con === null) {
  269. $con = Propel::getConnection(KataoNodeProductPeer::DATABASE_NAME);
  270. }
  271. try {
  272. $con->begin();
  273. $affectedRows = $this->doSave($con);
  274. $con->commit();
  275. foreach (sfMixer::getCallables('BaseKataoNodeProduct:save:post') as $callable)
  276. {
  277. call_user_func($callable, $this, $con, $affectedRows);
  278. }
  279. return $affectedRows;
  280. } catch (PropelException $e) {
  281. $con->rollback();
  282. throw $e;
  283. }
  284. }
  285. /**
  286. * Stores the object in the database.
  287. *
  288. * If the object is new, it inserts it; otherwise an update is performed.
  289. * All related objects are also updated in this method.
  290. *
  291. * @param Connection $con
  292. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  293. * @throws PropelException
  294. * @see save()
  295. */
  296. protected function doSave($con)
  297. {
  298. $affectedRows = 0; // initialize var to track total num of affected rows
  299. if (!$this->alreadyInSave) {
  300. $this->alreadyInSave = true;
  301. // We call the save method on the following object(s) if they
  302. // were passed to this object by their coresponding set
  303. // method. This object relates to these object(s) by a
  304. // foreign key reference.
  305. if ($this->aKataoNode !== null) {
  306. if ($this->aKataoNode->isModified()) {
  307. $affectedRows += $this->aKataoNode->save($con);
  308. }
  309. $this->setKataoNode($this->aKataoNode);
  310. }
  311. if ($this->aKataoPeriod !== null) {
  312. if ($this->aKataoPeriod->isModified()) {
  313. $affectedRows += $this->aKataoPeriod->save($con);
  314. }
  315. $this->setKataoPeriod($this->aKataoPeriod);
  316. }
  317. if ($this->aKataoProduct !== null) {
  318. if ($this->aKataoProduct->isModified()) {
  319. $affectedRows += $this->aKataoProduct->save($con);
  320. }
  321. $this->setKataoProduct($this->aKataoProduct);
  322. }
  323. // If this object has been modified, then save it to the database.
  324. if ($this->isModified()) {
  325. if ($this->isNew()) {
  326. $pk = KataoNodeProductPeer::doInsert($this, $con);
  327. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  328. // should always be true here (even though technically
  329. // BasePeer::doInsert() can insert multiple rows).
  330. $this->setId($pk); //[IMV] update autoincrement primary key
  331. $this->setNew(false);
  332. } else {
  333. $affectedRows += KataoNodeProductPeer::doUpdate($this, $con);
  334. }
  335. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  336. }
  337. $this->alreadyInSave = false;
  338. }
  339. return $affectedRows;
  340. } // doSave()
  341. /**
  342. * Array of ValidationFailed objects.
  343. * @var array ValidationFailed[]
  344. */
  345. protected $validationFailures = array();
  346. /**
  347. * Gets any ValidationFailed objects that resulted from last call to validate().
  348. *
  349. *
  350. * @return array ValidationFailed[]
  351. * @see validate()
  352. */
  353. public function getValidationFailures()
  354. {
  355. return $this->validationFailures;
  356. }
  357. /**
  358. * Validates the objects modified field values and all objects related to this table.
  359. *
  360. * If $columns is either a column name or an array of column names
  361. * only those columns are validated.
  362. *
  363. * @param mixed $columns Column name or an array of column names.
  364. * @return boolean Whether all columns pass validation.
  365. * @see doValidate()
  366. * @see getValidationFailures()
  367. */
  368. public function validate($columns = null)
  369. {
  370. $res = $this->doValidate($columns);
  371. if ($res === true) {
  372. $this->validationFailures = array();
  373. return true;
  374. } else {
  375. $this->validationFailures = $res;
  376. return false;
  377. }
  378. }
  379. /**
  380. * This function performs the validation work for complex object models.
  381. *
  382. * In addition to checking the current object, all related objects will
  383. * also be validated. If all pass then <code>true</code> is returned; otherwise
  384. * an aggreagated array of ValidationFailed objects will be returned.
  385. *
  386. * @param array $columns Array of column names to validate.
  387. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  388. */
  389. protected function doValidate($columns = null)
  390. {
  391. if (!$this->alreadyInValidation) {
  392. $this->alreadyInValidation = true;
  393. $retval = null;
  394. $failureMap = array();
  395. // We call the validate method on the following object(s) if they
  396. // were passed to this object by their coresponding set
  397. // method. This object relates to these object(s) by a
  398. // foreign key reference.
  399. if ($this->aKataoNode !== null) {
  400. if (!$this->aKataoNode->validate($columns)) {
  401. $failureMap = array_merge($failureMap, $this->aKataoNode->getValidationFailures());
  402. }
  403. }
  404. if ($this->aKataoPeriod !== null) {
  405. if (!$this->aKataoPeriod->validate($columns)) {
  406. $failureMap = array_merge($failureMap, $this->aKataoPeriod->getValidationFailures());
  407. }
  408. }
  409. if ($this->aKataoProduct !== null) {
  410. if (!$this->aKataoProduct->validate($columns)) {
  411. $failureMap = array_merge($failureMap, $this->aKataoProduct->getValidationFailures());
  412. }
  413. }
  414. if (($retval = KataoNodeProductPeer::doValidate($this, $columns)) !== true) {
  415. $failureMap = array_merge($failureMap, $retval);
  416. }
  417. $this->alreadyInValidation = false;
  418. }
  419. return (!empty($failureMap) ? $failureMap : true);
  420. }
  421. /**
  422. * Retrieves a field from the object by name passed in as a string.
  423. *
  424. * @param string $name name
  425. * @param string $type The type of fieldname the $name is of:
  426. * one of the class type constants TYPE_PHPNAME,
  427. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  428. * @return mixed Value of field.
  429. */
  430. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  431. {
  432. $pos = KataoNodeProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  433. return $this->getByPosition($pos);
  434. }
  435. /**
  436. * Retrieves a field from the object by Position as specified in the xml schema.
  437. * Zero-based.
  438. *
  439. * @param int $pos position in xml schema
  440. * @return mixed Value of field at $pos
  441. */
  442. public function getByPosition($pos)
  443. {
  444. switch($pos) {
  445. case 0:
  446. return $this->getId();
  447. break;
  448. case 1:
  449. return $this->getKataoNodeId();
  450. break;
  451. case 2:
  452. return $this->getKataoPeriodId();
  453. break;
  454. case 3:
  455. return $this->getKataoProductId();
  456. break;
  457. default:
  458. return null;
  459. break;
  460. } // switch()
  461. }
  462. /**
  463. * Exports the object as an array.
  464. *
  465. * You can specify the key type of the array by passing one of the class
  466. * type constants.
  467. *
  468. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  469. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  470. * @return an associative array containing the field names (as keys) and field values
  471. */
  472. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  473. {
  474. $keys = KataoNodeProductPeer::getFieldNames($keyType);
  475. $result = array(
  476. $keys[0] => $this->getId(),
  477. $keys[1] => $this->getKataoNodeId(),
  478. $keys[2] => $this->getKataoPeriodId(),
  479. $keys[3] => $this->getKataoProductId(),
  480. );
  481. return $result;
  482. }
  483. /**
  484. * Sets a field from the object by name passed in as a string.
  485. *
  486. * @param string $name peer name
  487. * @param mixed $value field value
  488. * @param string $type The type of fieldname the $name is of:
  489. * one of the class type constants TYPE_PHPNAME,
  490. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  491. * @return void
  492. */
  493. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  494. {
  495. $pos = KataoNodeProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  496. return $this->setByPosition($pos, $value);
  497. }
  498. /**
  499. * Sets a field from the object by Position as specified in the xml schema.
  500. * Zero-based.
  501. *
  502. * @param int $pos position in xml schema
  503. * @param mixed $value field value
  504. * @return void
  505. */
  506. public function setByPosition($pos, $value)
  507. {
  508. switch($pos) {
  509. case 0:
  510. $this->setId($value);
  511. break;
  512. case 1:
  513. $this->setKataoNodeId($value);
  514. break;
  515. case 2:
  516. $this->setKataoPeriodId($value);
  517. break;
  518. case 3:
  519. $this->setKataoProductId($value);
  520. break;
  521. } // switch()
  522. }
  523. /**
  524. * Populates the object using an array.
  525. *
  526. * This is particularly useful when populating an object from one of the
  527. * request arrays (e.g. $_POST). This method goes through the column
  528. * names, checking to see whether a matching key exists in populated
  529. * array. If so the setByName() method is called for that column.
  530. *
  531. * You can specify the key type of the array by additionally passing one
  532. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  533. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  534. *
  535. * @param array $arr An array to populate the object from.
  536. * @param string $keyType The type of keys the array uses.
  537. * @return void
  538. */
  539. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  540. {
  541. $keys = KataoNodeProductPeer::getFieldNames($keyType);
  542. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  543. if (array_key_exists($keys[1], $arr)) $this->setKataoNodeId($arr[$keys[1]]);
  544. if (array_key_exists($keys[2], $arr)) $this->setKataoPeriodId($arr[$keys[2]]);
  545. if (array_key_exists($keys[3], $arr)) $this->setKataoProductId($arr[$keys[3]]);
  546. }
  547. /**
  548. * Build a Criteria object containing the values of all modified columns in this object.
  549. *
  550. * @return Criteria The Criteria object containing all modified values.
  551. */
  552. public function buildCriteria()
  553. {
  554. $criteria = new Criteria(KataoNodeProductPeer::DATABASE_NAME);
  555. if ($this->isColumnModified(KataoNodeProductPeer::ID)) $criteria->add(KataoNodeProductPeer::ID, $this->id);
  556. if ($this->isColumnModified(KataoNodeProductPeer::KATAO_NODE_ID)) $criteria->add(KataoNodeProductPeer::KATAO_NODE_ID, $this->katao_node_id);
  557. if ($this->isColumnModified(KataoNodeProductPeer::KATAO_PERIOD_ID)) $criteria->add(KataoNodeProductPeer::KATAO_PERIOD_ID, $this->katao_period_id);
  558. if ($this->isColumnModified(KataoNodeProductPeer::KATAO_PRODUCT_ID)) $criteria->add(KataoNodeProductPeer::KATAO_PRODUCT_ID, $this->katao_product_id);
  559. return $criteria;
  560. }
  561. /**
  562. * Builds a Criteria object containing the primary key for this object.
  563. *
  564. * Unlike buildCriteria() this method includes the primary key values regardless
  565. * of whether or not they have been modified.
  566. *
  567. * @return Criteria The Criteria object containing value(s) for primary key(s).
  568. */
  569. public function buildPkeyCriteria()
  570. {
  571. $criteria = new Criteria(KataoNodeProductPeer::DATABASE_NAME);
  572. $criteria->add(KataoNodeProductPeer::ID, $this->id);
  573. return $criteria;
  574. }
  575. /**
  576. * Returns the primary key for this object (row).
  577. * @return int
  578. */
  579. public function getPrimaryKey()
  580. {
  581. return $this->getId();
  582. }
  583. /**
  584. * Generic method to set the primary key (id column).
  585. *
  586. * @param int $key Primary key.
  587. * @return void
  588. */
  589. public function setPrimaryKey($key)
  590. {
  591. $this->setId($key);
  592. }
  593. /**
  594. * Sets contents of passed object to values from current object.
  595. *
  596. * If desired, this method can also make copies of all associated (fkey referrers)
  597. * objects.
  598. *
  599. * @param object $copyObj An object of KataoNodeProduct (or compatible) type.
  600. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  601. * @throws PropelException
  602. */
  603. public function copyInto($copyObj, $deepCopy = false)
  604. {
  605. $copyObj->setKataoNodeId($this->katao_node_id);
  606. $copyObj->setKataoPeriodId($this->katao_period_id);
  607. $copyObj->setKataoProductId($this->katao_product_id);
  608. $copyObj->setNew(true);
  609. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  610. }
  611. /**
  612. * Makes a copy of this object that will be inserted as a new row in table when saved.
  613. * It creates a new object filling in the simple attributes, but skipping any primary
  614. * keys that are defined for the table.
  615. *
  616. * If desired, this method can also make copies of all associated (fkey referrers)
  617. * objects.
  618. *
  619. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  620. * @return KataoNodeProduct Clone of current object.
  621. * @throws PropelException
  622. */
  623. public function copy($deepCopy = false)
  624. {
  625. // we use get_class(), because this might be a subclass
  626. $clazz = get_class($this);
  627. $copyObj = new $clazz();
  628. $this->copyInto($copyObj, $deepCopy);
  629. return $copyObj;
  630. }
  631. /**
  632. * Returns a peer instance associated with this om.
  633. *
  634. * Since Peer classes are not to have any instance attributes, this method returns the
  635. * same instance for all member of this class. The method could therefore
  636. * be static, but this would prevent one from overriding the behavior.
  637. *
  638. * @return KataoNodeProductPeer
  639. */
  640. public function getPeer()
  641. {
  642. if (self::$peer === null) {
  643. self::$peer = new KataoNodeProductPeer();
  644. }
  645. return self::$peer;
  646. }
  647. /**
  648. * Declares an association between this object and a KataoNode object.
  649. *
  650. * @param KataoNode $v
  651. * @return void
  652. * @throws PropelException
  653. */
  654. public function setKataoNode($v)
  655. {
  656. if ($v === null) {
  657. $this->setKataoNodeId(NULL);
  658. } else {
  659. $this->setKataoNodeId($v->getId());
  660. }
  661. $this->aKataoNode = $v;
  662. }
  663. /**
  664. * Get the associated KataoNode object
  665. *
  666. * @param Connection Optional Connection object.
  667. * @return KataoNode The associated KataoNode object.
  668. * @throws PropelException
  669. */
  670. public function getKataoNode($con = null)
  671. {
  672. if ($this->aKataoNode === null && ($this->katao_node_id !== null)) {
  673. // include the related Peer class
  674. $this->aKataoNode = KataoNodePeer::retrieveByPK($this->katao_node_id, $con);
  675. /* The following can be used instead of the line above to
  676. guarantee the related object contains a reference
  677. to this object, but this level of coupling
  678. may be undesirable in many circumstances.
  679. As it can lead to a db query with many results that may
  680. never be used.
  681. $obj = KataoNodePeer::retrieveByPK($this->katao_node_id, $con);
  682. $obj->addKataoNodes($this);
  683. */
  684. }
  685. return $this->aKataoNode;
  686. }
  687. /**
  688. * Declares an association between this object and a KataoPeriod object.
  689. *
  690. * @param KataoPeriod $v
  691. * @return void
  692. * @throws PropelException
  693. */
  694. public function setKataoPeriod($v)
  695. {
  696. if ($v === null) {
  697. $this->setKataoPeriodId(NULL);
  698. } else {
  699. $this->setKataoPeriodId($v->getId());
  700. }
  701. $this->aKataoPeriod = $v;
  702. }
  703. /**
  704. * Get the associated KataoPeriod object
  705. *
  706. * @param Connection Optional Connection object.
  707. * @return KataoPeriod The associated KataoPeriod object.
  708. * @throws PropelException
  709. */
  710. public function getKataoPeriod($con = null)
  711. {
  712. if ($this->aKataoPeriod === null && ($this->katao_period_id !== null)) {
  713. // include the related Peer class
  714. $this->aKataoPeriod = KataoPeriodPeer::retrieveByPK($this->katao_period_id, $con);
  715. /* The following can be used instead of the line above to
  716. guarantee the related object contains a reference
  717. to this object, but this level of coupling
  718. may be undesirable in many circumstances.
  719. As it can lead to a db query with many results that may
  720. never be used.
  721. $obj = KataoPeriodPeer::retrieveByPK($this->katao_period_id, $con);
  722. $obj->addKataoPeriods($this);
  723. */
  724. }
  725. return $this->aKataoPeriod;
  726. }
  727. /**
  728. * Declares an association between this object and a KataoProduct object.
  729. *
  730. * @param KataoProduct $v
  731. * @return void
  732. * @throws PropelException
  733. */
  734. public function setKataoProduct($v)
  735. {
  736. if ($v === null) {
  737. $this->setKataoProductId(NULL);
  738. } else {
  739. $this->setKataoProductId($v->getId());
  740. }
  741. $this->aKataoProduct = $v;
  742. }
  743. /**
  744. * Get the associated KataoProduct object
  745. *
  746. * @param Connection Optional Connection object.
  747. * @return KataoProduct The associated KataoProduct object.
  748. * @throws PropelException
  749. */
  750. public function getKataoProduct($con = null)
  751. {
  752. if ($this->aKataoProduct === null && ($this->katao_product_id !== null)) {
  753. // include the related Peer class
  754. $this->aKataoProduct = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  755. /* The following can be used instead of the line above to
  756. guarantee the related object contains a reference
  757. to this object, but this level of coupling
  758. may be undesirable in many circumstances.
  759. As it can lead to a db query with many results that may
  760. never be used.
  761. $obj = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  762. $obj->addKataoProducts($this);
  763. */
  764. }
  765. return $this->aKataoProduct;
  766. }
  767. public function __call($method, $arguments)
  768. {
  769. if (!$callable = sfMixer::getCallable('BaseKataoNodeProduct:'.$method))
  770. {
  771. throw new sfException(sprintf('Call to undefined method BaseKataoNodeProduct::%s', $method));
  772. }
  773. array_unshift($arguments, $this);
  774. return call_user_func_array($callable, $arguments);
  775. }
  776. } // BaseKataoNodeProduct