BaseKataoProductFamily.php 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. <?php
  2. /**
  3. * Base class that represents a row from the 'katao_product_family' table.
  4. *
  5. *
  6. *
  7. * @package lib.model.om
  8. */
  9. abstract class BaseKataoProductFamily 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 KataoProductFamilyPeer
  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_product_category_id field.
  24. * @var int
  25. */
  26. protected $katao_product_category_id;
  27. /**
  28. * The value for the name field.
  29. * @var string
  30. */
  31. protected $name;
  32. /**
  33. * The value for the url_identifier field.
  34. * @var string
  35. */
  36. protected $url_identifier;
  37. /**
  38. * The value for the created_at field.
  39. * @var int
  40. */
  41. protected $created_at;
  42. /**
  43. * The value for the updated_at field.
  44. * @var int
  45. */
  46. protected $updated_at;
  47. /**
  48. * @var KataoProductCategory
  49. */
  50. protected $aKataoProductCategory;
  51. /**
  52. * Collection to store aggregation of collKataoProducts.
  53. * @var array
  54. */
  55. protected $collKataoProducts;
  56. /**
  57. * The criteria used to select the current contents of collKataoProducts.
  58. * @var Criteria
  59. */
  60. protected $lastKataoProductCriteria = null;
  61. /**
  62. * Flag to prevent endless save loop, if this object is referenced
  63. * by another object which falls in this transaction.
  64. * @var boolean
  65. */
  66. protected $alreadyInSave = false;
  67. /**
  68. * Flag to prevent endless validation loop, if this object is referenced
  69. * by another object which falls in this transaction.
  70. * @var boolean
  71. */
  72. protected $alreadyInValidation = false;
  73. /**
  74. * Get the [id] column value.
  75. *
  76. * @return int
  77. */
  78. public function getId()
  79. {
  80. return $this->id;
  81. }
  82. /**
  83. * Get the [katao_product_category_id] column value.
  84. *
  85. * @return int
  86. */
  87. public function getKataoProductCategoryId()
  88. {
  89. return $this->katao_product_category_id;
  90. }
  91. /**
  92. * Get the [name] column value.
  93. *
  94. * @return string
  95. */
  96. public function getName()
  97. {
  98. return $this->name;
  99. }
  100. /**
  101. * Get the [url_identifier] column value.
  102. *
  103. * @return string
  104. */
  105. public function getUrlIdentifier()
  106. {
  107. return $this->url_identifier;
  108. }
  109. /**
  110. * Get the [optionally formatted] [created_at] column value.
  111. *
  112. * @param string $format The date/time format string (either date()-style or strftime()-style).
  113. * If format is NULL, then the integer unix timestamp will be returned.
  114. * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
  115. * @throws PropelException - if unable to convert the date/time to timestamp.
  116. */
  117. public function getCreatedAt($format = 'Y-m-d H:i:s')
  118. {
  119. if ($this->created_at === null || $this->created_at === '') {
  120. return null;
  121. } elseif (!is_int($this->created_at)) {
  122. // a non-timestamp value was set externally, so we convert it
  123. $ts = strtotime($this->created_at);
  124. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  125. throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
  126. }
  127. } else {
  128. $ts = $this->created_at;
  129. }
  130. if ($format === null) {
  131. return $ts;
  132. } elseif (strpos($format, '%') !== false) {
  133. return strftime($format, $ts);
  134. } else {
  135. return date($format, $ts);
  136. }
  137. }
  138. /**
  139. * Get the [optionally formatted] [updated_at] column value.
  140. *
  141. * @param string $format The date/time format string (either date()-style or strftime()-style).
  142. * If format is NULL, then the integer unix timestamp will be returned.
  143. * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
  144. * @throws PropelException - if unable to convert the date/time to timestamp.
  145. */
  146. public function getUpdatedAt($format = 'Y-m-d H:i:s')
  147. {
  148. if ($this->updated_at === null || $this->updated_at === '') {
  149. return null;
  150. } elseif (!is_int($this->updated_at)) {
  151. // a non-timestamp value was set externally, so we convert it
  152. $ts = strtotime($this->updated_at);
  153. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  154. throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
  155. }
  156. } else {
  157. $ts = $this->updated_at;
  158. }
  159. if ($format === null) {
  160. return $ts;
  161. } elseif (strpos($format, '%') !== false) {
  162. return strftime($format, $ts);
  163. } else {
  164. return date($format, $ts);
  165. }
  166. }
  167. /**
  168. * Set the value of [id] column.
  169. *
  170. * @param int $v new value
  171. * @return void
  172. */
  173. public function setId($v)
  174. {
  175. // Since the native PHP type for this column is integer,
  176. // we will cast the input value to an int (if it is not).
  177. if ($v !== null && !is_int($v) && is_numeric($v)) {
  178. $v = (int) $v;
  179. }
  180. if ($this->id !== $v) {
  181. $this->id = $v;
  182. $this->modifiedColumns[] = KataoProductFamilyPeer::ID;
  183. }
  184. } // setId()
  185. /**
  186. * Set the value of [katao_product_category_id] column.
  187. *
  188. * @param int $v new value
  189. * @return void
  190. */
  191. public function setKataoProductCategoryId($v)
  192. {
  193. // Since the native PHP type for this column is integer,
  194. // we will cast the input value to an int (if it is not).
  195. if ($v !== null && !is_int($v) && is_numeric($v)) {
  196. $v = (int) $v;
  197. }
  198. if ($this->katao_product_category_id !== $v) {
  199. $this->katao_product_category_id = $v;
  200. $this->modifiedColumns[] = KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID;
  201. }
  202. if ($this->aKataoProductCategory !== null && $this->aKataoProductCategory->getId() !== $v) {
  203. $this->aKataoProductCategory = null;
  204. }
  205. } // setKataoProductCategoryId()
  206. /**
  207. * Set the value of [name] column.
  208. *
  209. * @param string $v new value
  210. * @return void
  211. */
  212. public function setName($v)
  213. {
  214. // Since the native PHP type for this column is string,
  215. // we will cast the input to a string (if it is not).
  216. if ($v !== null && !is_string($v)) {
  217. $v = (string) $v;
  218. }
  219. if ($this->name !== $v) {
  220. $this->name = $v;
  221. $this->modifiedColumns[] = KataoProductFamilyPeer::NAME;
  222. }
  223. } // setName()
  224. /**
  225. * Set the value of [url_identifier] column.
  226. *
  227. * @param string $v new value
  228. * @return void
  229. */
  230. public function setUrlIdentifier($v)
  231. {
  232. // Since the native PHP type for this column is string,
  233. // we will cast the input to a string (if it is not).
  234. if ($v !== null && !is_string($v)) {
  235. $v = (string) $v;
  236. }
  237. if ($this->url_identifier !== $v) {
  238. $this->url_identifier = $v;
  239. $this->modifiedColumns[] = KataoProductFamilyPeer::URL_IDENTIFIER;
  240. }
  241. } // setUrlIdentifier()
  242. /**
  243. * Set the value of [created_at] column.
  244. *
  245. * @param int $v new value
  246. * @return void
  247. */
  248. public function setCreatedAt($v)
  249. {
  250. if ($v !== null && !is_int($v)) {
  251. $ts = strtotime($v);
  252. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  253. throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
  254. }
  255. } else {
  256. $ts = $v;
  257. }
  258. if ($this->created_at !== $ts) {
  259. $this->created_at = $ts;
  260. $this->modifiedColumns[] = KataoProductFamilyPeer::CREATED_AT;
  261. }
  262. } // setCreatedAt()
  263. /**
  264. * Set the value of [updated_at] column.
  265. *
  266. * @param int $v new value
  267. * @return void
  268. */
  269. public function setUpdatedAt($v)
  270. {
  271. if ($v !== null && !is_int($v)) {
  272. $ts = strtotime($v);
  273. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  274. throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
  275. }
  276. } else {
  277. $ts = $v;
  278. }
  279. if ($this->updated_at !== $ts) {
  280. $this->updated_at = $ts;
  281. $this->modifiedColumns[] = KataoProductFamilyPeer::UPDATED_AT;
  282. }
  283. } // setUpdatedAt()
  284. /**
  285. * Hydrates (populates) the object variables with values from the database resultset.
  286. *
  287. * An offset (1-based "start column") is specified so that objects can be hydrated
  288. * with a subset of the columns in the resultset rows. This is needed, for example,
  289. * for results of JOIN queries where the resultset row includes columns from two or
  290. * more tables.
  291. *
  292. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  293. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  294. * @return int next starting column
  295. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  296. */
  297. public function hydrate(ResultSet $rs, $startcol = 1)
  298. {
  299. try {
  300. $this->id = $rs->getInt($startcol + 0);
  301. $this->katao_product_category_id = $rs->getInt($startcol + 1);
  302. $this->name = $rs->getString($startcol + 2);
  303. $this->url_identifier = $rs->getString($startcol + 3);
  304. $this->created_at = $rs->getTimestamp($startcol + 4, null);
  305. $this->updated_at = $rs->getTimestamp($startcol + 5, null);
  306. $this->resetModified();
  307. $this->setNew(false);
  308. // FIXME - using NUM_COLUMNS may be clearer.
  309. return $startcol + 6; // 6 = KataoProductFamilyPeer::NUM_COLUMNS - KataoProductFamilyPeer::NUM_LAZY_LOAD_COLUMNS).
  310. } catch (Exception $e) {
  311. throw new PropelException("Error populating KataoProductFamily object", $e);
  312. }
  313. }
  314. /**
  315. * Removes this object from datastore and sets delete attribute.
  316. *
  317. * @param Connection $con
  318. * @return void
  319. * @throws PropelException
  320. * @see BaseObject::setDeleted()
  321. * @see BaseObject::isDeleted()
  322. */
  323. public function delete($con = null)
  324. {
  325. foreach (sfMixer::getCallables('BaseKataoProductFamily:delete:pre') as $callable)
  326. {
  327. $ret = call_user_func($callable, $this, $con);
  328. if ($ret)
  329. {
  330. return;
  331. }
  332. }
  333. if ($this->isDeleted()) {
  334. throw new PropelException("This object has already been deleted.");
  335. }
  336. if ($con === null) {
  337. $con = Propel::getConnection(KataoProductFamilyPeer::DATABASE_NAME);
  338. }
  339. try {
  340. $con->begin();
  341. KataoProductFamilyPeer::doDelete($this, $con);
  342. $this->setDeleted(true);
  343. $con->commit();
  344. } catch (PropelException $e) {
  345. $con->rollback();
  346. throw $e;
  347. }
  348. foreach (sfMixer::getCallables('BaseKataoProductFamily:delete:post') as $callable)
  349. {
  350. call_user_func($callable, $this, $con);
  351. }
  352. }
  353. /**
  354. * Stores the object in the database. If the object is new,
  355. * it inserts it; otherwise an update is performed. This method
  356. * wraps the doSave() worker method in a transaction.
  357. *
  358. * @param Connection $con
  359. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  360. * @throws PropelException
  361. * @see doSave()
  362. */
  363. public function save($con = null)
  364. {
  365. foreach (sfMixer::getCallables('BaseKataoProductFamily:save:pre') as $callable)
  366. {
  367. $affectedRows = call_user_func($callable, $this, $con);
  368. if (is_int($affectedRows))
  369. {
  370. return $affectedRows;
  371. }
  372. }
  373. if ($this->isNew() && !$this->isColumnModified(KataoProductFamilyPeer::CREATED_AT))
  374. {
  375. $this->setCreatedAt(time());
  376. }
  377. if ($this->isModified() && !$this->isColumnModified(KataoProductFamilyPeer::UPDATED_AT))
  378. {
  379. $this->setUpdatedAt(time());
  380. }
  381. if ($this->isDeleted()) {
  382. throw new PropelException("You cannot save an object that has been deleted.");
  383. }
  384. if ($con === null) {
  385. $con = Propel::getConnection(KataoProductFamilyPeer::DATABASE_NAME);
  386. }
  387. try {
  388. $con->begin();
  389. $affectedRows = $this->doSave($con);
  390. $con->commit();
  391. foreach (sfMixer::getCallables('BaseKataoProductFamily:save:post') as $callable)
  392. {
  393. call_user_func($callable, $this, $con, $affectedRows);
  394. }
  395. return $affectedRows;
  396. } catch (PropelException $e) {
  397. $con->rollback();
  398. throw $e;
  399. }
  400. }
  401. /**
  402. * Stores the object in the database.
  403. *
  404. * If the object is new, it inserts it; otherwise an update is performed.
  405. * All related objects are also updated in this method.
  406. *
  407. * @param Connection $con
  408. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  409. * @throws PropelException
  410. * @see save()
  411. */
  412. protected function doSave($con)
  413. {
  414. $affectedRows = 0; // initialize var to track total num of affected rows
  415. if (!$this->alreadyInSave) {
  416. $this->alreadyInSave = true;
  417. // We call the save method on the following object(s) if they
  418. // were passed to this object by their coresponding set
  419. // method. This object relates to these object(s) by a
  420. // foreign key reference.
  421. if ($this->aKataoProductCategory !== null) {
  422. if ($this->aKataoProductCategory->isModified()) {
  423. $affectedRows += $this->aKataoProductCategory->save($con);
  424. }
  425. $this->setKataoProductCategory($this->aKataoProductCategory);
  426. }
  427. // If this object has been modified, then save it to the database.
  428. if ($this->isModified()) {
  429. if ($this->isNew()) {
  430. $pk = KataoProductFamilyPeer::doInsert($this, $con);
  431. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  432. // should always be true here (even though technically
  433. // BasePeer::doInsert() can insert multiple rows).
  434. $this->setId($pk); //[IMV] update autoincrement primary key
  435. $this->setNew(false);
  436. } else {
  437. $affectedRows += KataoProductFamilyPeer::doUpdate($this, $con);
  438. }
  439. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  440. }
  441. if ($this->collKataoProducts !== null) {
  442. foreach($this->collKataoProducts as $referrerFK) {
  443. if (!$referrerFK->isDeleted()) {
  444. $affectedRows += $referrerFK->save($con);
  445. }
  446. }
  447. }
  448. $this->alreadyInSave = false;
  449. }
  450. return $affectedRows;
  451. } // doSave()
  452. /**
  453. * Array of ValidationFailed objects.
  454. * @var array ValidationFailed[]
  455. */
  456. protected $validationFailures = array();
  457. /**
  458. * Gets any ValidationFailed objects that resulted from last call to validate().
  459. *
  460. *
  461. * @return array ValidationFailed[]
  462. * @see validate()
  463. */
  464. public function getValidationFailures()
  465. {
  466. return $this->validationFailures;
  467. }
  468. /**
  469. * Validates the objects modified field values and all objects related to this table.
  470. *
  471. * If $columns is either a column name or an array of column names
  472. * only those columns are validated.
  473. *
  474. * @param mixed $columns Column name or an array of column names.
  475. * @return boolean Whether all columns pass validation.
  476. * @see doValidate()
  477. * @see getValidationFailures()
  478. */
  479. public function validate($columns = null)
  480. {
  481. $res = $this->doValidate($columns);
  482. if ($res === true) {
  483. $this->validationFailures = array();
  484. return true;
  485. } else {
  486. $this->validationFailures = $res;
  487. return false;
  488. }
  489. }
  490. /**
  491. * This function performs the validation work for complex object models.
  492. *
  493. * In addition to checking the current object, all related objects will
  494. * also be validated. If all pass then <code>true</code> is returned; otherwise
  495. * an aggreagated array of ValidationFailed objects will be returned.
  496. *
  497. * @param array $columns Array of column names to validate.
  498. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  499. */
  500. protected function doValidate($columns = null)
  501. {
  502. if (!$this->alreadyInValidation) {
  503. $this->alreadyInValidation = true;
  504. $retval = null;
  505. $failureMap = array();
  506. // We call the validate method on the following object(s) if they
  507. // were passed to this object by their coresponding set
  508. // method. This object relates to these object(s) by a
  509. // foreign key reference.
  510. if ($this->aKataoProductCategory !== null) {
  511. if (!$this->aKataoProductCategory->validate($columns)) {
  512. $failureMap = array_merge($failureMap, $this->aKataoProductCategory->getValidationFailures());
  513. }
  514. }
  515. if (($retval = KataoProductFamilyPeer::doValidate($this, $columns)) !== true) {
  516. $failureMap = array_merge($failureMap, $retval);
  517. }
  518. if ($this->collKataoProducts !== null) {
  519. foreach($this->collKataoProducts as $referrerFK) {
  520. if (!$referrerFK->validate($columns)) {
  521. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  522. }
  523. }
  524. }
  525. $this->alreadyInValidation = false;
  526. }
  527. return (!empty($failureMap) ? $failureMap : true);
  528. }
  529. /**
  530. * Retrieves a field from the object by name passed in as a string.
  531. *
  532. * @param string $name name
  533. * @param string $type The type of fieldname the $name is of:
  534. * one of the class type constants TYPE_PHPNAME,
  535. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  536. * @return mixed Value of field.
  537. */
  538. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  539. {
  540. $pos = KataoProductFamilyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  541. return $this->getByPosition($pos);
  542. }
  543. /**
  544. * Retrieves a field from the object by Position as specified in the xml schema.
  545. * Zero-based.
  546. *
  547. * @param int $pos position in xml schema
  548. * @return mixed Value of field at $pos
  549. */
  550. public function getByPosition($pos)
  551. {
  552. switch($pos) {
  553. case 0:
  554. return $this->getId();
  555. break;
  556. case 1:
  557. return $this->getKataoProductCategoryId();
  558. break;
  559. case 2:
  560. return $this->getName();
  561. break;
  562. case 3:
  563. return $this->getUrlIdentifier();
  564. break;
  565. case 4:
  566. return $this->getCreatedAt();
  567. break;
  568. case 5:
  569. return $this->getUpdatedAt();
  570. break;
  571. default:
  572. return null;
  573. break;
  574. } // switch()
  575. }
  576. /**
  577. * Exports the object as an array.
  578. *
  579. * You can specify the key type of the array by passing one of the class
  580. * type constants.
  581. *
  582. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  583. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  584. * @return an associative array containing the field names (as keys) and field values
  585. */
  586. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  587. {
  588. $keys = KataoProductFamilyPeer::getFieldNames($keyType);
  589. $result = array(
  590. $keys[0] => $this->getId(),
  591. $keys[1] => $this->getKataoProductCategoryId(),
  592. $keys[2] => $this->getName(),
  593. $keys[3] => $this->getUrlIdentifier(),
  594. $keys[4] => $this->getCreatedAt(),
  595. $keys[5] => $this->getUpdatedAt(),
  596. );
  597. return $result;
  598. }
  599. /**
  600. * Sets a field from the object by name passed in as a string.
  601. *
  602. * @param string $name peer name
  603. * @param mixed $value field value
  604. * @param string $type The type of fieldname the $name is of:
  605. * one of the class type constants TYPE_PHPNAME,
  606. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  607. * @return void
  608. */
  609. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  610. {
  611. $pos = KataoProductFamilyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  612. return $this->setByPosition($pos, $value);
  613. }
  614. /**
  615. * Sets a field from the object by Position as specified in the xml schema.
  616. * Zero-based.
  617. *
  618. * @param int $pos position in xml schema
  619. * @param mixed $value field value
  620. * @return void
  621. */
  622. public function setByPosition($pos, $value)
  623. {
  624. switch($pos) {
  625. case 0:
  626. $this->setId($value);
  627. break;
  628. case 1:
  629. $this->setKataoProductCategoryId($value);
  630. break;
  631. case 2:
  632. $this->setName($value);
  633. break;
  634. case 3:
  635. $this->setUrlIdentifier($value);
  636. break;
  637. case 4:
  638. $this->setCreatedAt($value);
  639. break;
  640. case 5:
  641. $this->setUpdatedAt($value);
  642. break;
  643. } // switch()
  644. }
  645. /**
  646. * Populates the object using an array.
  647. *
  648. * This is particularly useful when populating an object from one of the
  649. * request arrays (e.g. $_POST). This method goes through the column
  650. * names, checking to see whether a matching key exists in populated
  651. * array. If so the setByName() method is called for that column.
  652. *
  653. * You can specify the key type of the array by additionally passing one
  654. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  655. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  656. *
  657. * @param array $arr An array to populate the object from.
  658. * @param string $keyType The type of keys the array uses.
  659. * @return void
  660. */
  661. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  662. {
  663. $keys = KataoProductFamilyPeer::getFieldNames($keyType);
  664. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  665. if (array_key_exists($keys[1], $arr)) $this->setKataoProductCategoryId($arr[$keys[1]]);
  666. if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
  667. if (array_key_exists($keys[3], $arr)) $this->setUrlIdentifier($arr[$keys[3]]);
  668. if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]);
  669. if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]);
  670. }
  671. /**
  672. * Build a Criteria object containing the values of all modified columns in this object.
  673. *
  674. * @return Criteria The Criteria object containing all modified values.
  675. */
  676. public function buildCriteria()
  677. {
  678. $criteria = new Criteria(KataoProductFamilyPeer::DATABASE_NAME);
  679. if ($this->isColumnModified(KataoProductFamilyPeer::ID)) $criteria->add(KataoProductFamilyPeer::ID, $this->id);
  680. if ($this->isColumnModified(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID)) $criteria->add(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, $this->katao_product_category_id);
  681. if ($this->isColumnModified(KataoProductFamilyPeer::NAME)) $criteria->add(KataoProductFamilyPeer::NAME, $this->name);
  682. if ($this->isColumnModified(KataoProductFamilyPeer::URL_IDENTIFIER)) $criteria->add(KataoProductFamilyPeer::URL_IDENTIFIER, $this->url_identifier);
  683. if ($this->isColumnModified(KataoProductFamilyPeer::CREATED_AT)) $criteria->add(KataoProductFamilyPeer::CREATED_AT, $this->created_at);
  684. if ($this->isColumnModified(KataoProductFamilyPeer::UPDATED_AT)) $criteria->add(KataoProductFamilyPeer::UPDATED_AT, $this->updated_at);
  685. return $criteria;
  686. }
  687. /**
  688. * Builds a Criteria object containing the primary key for this object.
  689. *
  690. * Unlike buildCriteria() this method includes the primary key values regardless
  691. * of whether or not they have been modified.
  692. *
  693. * @return Criteria The Criteria object containing value(s) for primary key(s).
  694. */
  695. public function buildPkeyCriteria()
  696. {
  697. $criteria = new Criteria(KataoProductFamilyPeer::DATABASE_NAME);
  698. $criteria->add(KataoProductFamilyPeer::ID, $this->id);
  699. return $criteria;
  700. }
  701. /**
  702. * Returns the primary key for this object (row).
  703. * @return int
  704. */
  705. public function getPrimaryKey()
  706. {
  707. return $this->getId();
  708. }
  709. /**
  710. * Generic method to set the primary key (id column).
  711. *
  712. * @param int $key Primary key.
  713. * @return void
  714. */
  715. public function setPrimaryKey($key)
  716. {
  717. $this->setId($key);
  718. }
  719. /**
  720. * Sets contents of passed object to values from current object.
  721. *
  722. * If desired, this method can also make copies of all associated (fkey referrers)
  723. * objects.
  724. *
  725. * @param object $copyObj An object of KataoProductFamily (or compatible) type.
  726. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  727. * @throws PropelException
  728. */
  729. public function copyInto($copyObj, $deepCopy = false)
  730. {
  731. $copyObj->setKataoProductCategoryId($this->katao_product_category_id);
  732. $copyObj->setName($this->name);
  733. $copyObj->setUrlIdentifier($this->url_identifier);
  734. $copyObj->setCreatedAt($this->created_at);
  735. $copyObj->setUpdatedAt($this->updated_at);
  736. if ($deepCopy) {
  737. // important: temporarily setNew(false) because this affects the behavior of
  738. // the getter/setter methods for fkey referrer objects.
  739. $copyObj->setNew(false);
  740. foreach($this->getKataoProducts() as $relObj) {
  741. $copyObj->addKataoProduct($relObj->copy($deepCopy));
  742. }
  743. } // if ($deepCopy)
  744. $copyObj->setNew(true);
  745. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  746. }
  747. /**
  748. * Makes a copy of this object that will be inserted as a new row in table when saved.
  749. * It creates a new object filling in the simple attributes, but skipping any primary
  750. * keys that are defined for the table.
  751. *
  752. * If desired, this method can also make copies of all associated (fkey referrers)
  753. * objects.
  754. *
  755. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  756. * @return KataoProductFamily Clone of current object.
  757. * @throws PropelException
  758. */
  759. public function copy($deepCopy = false)
  760. {
  761. // we use get_class(), because this might be a subclass
  762. $clazz = get_class($this);
  763. $copyObj = new $clazz();
  764. $this->copyInto($copyObj, $deepCopy);
  765. return $copyObj;
  766. }
  767. /**
  768. * Returns a peer instance associated with this om.
  769. *
  770. * Since Peer classes are not to have any instance attributes, this method returns the
  771. * same instance for all member of this class. The method could therefore
  772. * be static, but this would prevent one from overriding the behavior.
  773. *
  774. * @return KataoProductFamilyPeer
  775. */
  776. public function getPeer()
  777. {
  778. if (self::$peer === null) {
  779. self::$peer = new KataoProductFamilyPeer();
  780. }
  781. return self::$peer;
  782. }
  783. /**
  784. * Declares an association between this object and a KataoProductCategory object.
  785. *
  786. * @param KataoProductCategory $v
  787. * @return void
  788. * @throws PropelException
  789. */
  790. public function setKataoProductCategory($v)
  791. {
  792. if ($v === null) {
  793. $this->setKataoProductCategoryId(NULL);
  794. } else {
  795. $this->setKataoProductCategoryId($v->getId());
  796. }
  797. $this->aKataoProductCategory = $v;
  798. }
  799. /**
  800. * Get the associated KataoProductCategory object
  801. *
  802. * @param Connection Optional Connection object.
  803. * @return KataoProductCategory The associated KataoProductCategory object.
  804. * @throws PropelException
  805. */
  806. public function getKataoProductCategory($con = null)
  807. {
  808. if ($this->aKataoProductCategory === null && ($this->katao_product_category_id !== null)) {
  809. // include the related Peer class
  810. $this->aKataoProductCategory = KataoProductCategoryPeer::retrieveByPK($this->katao_product_category_id, $con);
  811. /* The following can be used instead of the line above to
  812. guarantee the related object contains a reference
  813. to this object, but this level of coupling
  814. may be undesirable in many circumstances.
  815. As it can lead to a db query with many results that may
  816. never be used.
  817. $obj = KataoProductCategoryPeer::retrieveByPK($this->katao_product_category_id, $con);
  818. $obj->addKataoProductCategorys($this);
  819. */
  820. }
  821. return $this->aKataoProductCategory;
  822. }
  823. /**
  824. * Temporary storage of collKataoProducts to save a possible db hit in
  825. * the event objects are add to the collection, but the
  826. * complete collection is never requested.
  827. * @return void
  828. */
  829. public function initKataoProducts()
  830. {
  831. if ($this->collKataoProducts === null) {
  832. $this->collKataoProducts = array();
  833. }
  834. }
  835. /**
  836. * If this collection has already been initialized with
  837. * an identical criteria, it returns the collection.
  838. * Otherwise if this KataoProductFamily has previously
  839. * been saved, it will retrieve related KataoProducts from storage.
  840. * If this KataoProductFamily is new, it will return
  841. * an empty collection or the current collection, the criteria
  842. * is ignored on a new object.
  843. *
  844. * @param Connection $con
  845. * @param Criteria $criteria
  846. * @throws PropelException
  847. */
  848. public function getKataoProducts($criteria = null, $con = null)
  849. {
  850. // include the Peer class
  851. if ($criteria === null) {
  852. $criteria = new Criteria();
  853. }
  854. elseif ($criteria instanceof Criteria)
  855. {
  856. $criteria = clone $criteria;
  857. }
  858. if ($this->collKataoProducts === null) {
  859. if ($this->isNew()) {
  860. $this->collKataoProducts = array();
  861. } else {
  862. $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->getId());
  863. KataoProductPeer::addSelectColumns($criteria);
  864. $this->collKataoProducts = KataoProductPeer::doSelect($criteria, $con);
  865. }
  866. } else {
  867. // criteria has no effect for a new object
  868. if (!$this->isNew()) {
  869. // the following code is to determine if a new query is
  870. // called for. If the criteria is the same as the last
  871. // one, just return the collection.
  872. $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->getId());
  873. KataoProductPeer::addSelectColumns($criteria);
  874. if (!isset($this->lastKataoProductCriteria) || !$this->lastKataoProductCriteria->equals($criteria)) {
  875. $this->collKataoProducts = KataoProductPeer::doSelect($criteria, $con);
  876. }
  877. }
  878. }
  879. $this->lastKataoProductCriteria = $criteria;
  880. return $this->collKataoProducts;
  881. }
  882. /**
  883. * Returns the number of related KataoProducts.
  884. *
  885. * @param Criteria $criteria
  886. * @param boolean $distinct
  887. * @param Connection $con
  888. * @throws PropelException
  889. */
  890. public function countKataoProducts($criteria = null, $distinct = false, $con = null)
  891. {
  892. // include the Peer class
  893. if ($criteria === null) {
  894. $criteria = new Criteria();
  895. }
  896. elseif ($criteria instanceof Criteria)
  897. {
  898. $criteria = clone $criteria;
  899. }
  900. $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->getId());
  901. return KataoProductPeer::doCount($criteria, $distinct, $con);
  902. }
  903. /**
  904. * Method called to associate a KataoProduct object to this object
  905. * through the KataoProduct foreign key attribute
  906. *
  907. * @param KataoProduct $l KataoProduct
  908. * @return void
  909. * @throws PropelException
  910. */
  911. public function addKataoProduct(KataoProduct $l)
  912. {
  913. $this->collKataoProducts[] = $l;
  914. $l->setKataoProductFamily($this);
  915. }
  916. /**
  917. * If this collection has already been initialized with
  918. * an identical criteria, it returns the collection.
  919. * Otherwise if this KataoProductFamily is new, it will return
  920. * an empty collection; or if this KataoProductFamily has previously
  921. * been saved, it will retrieve related KataoProducts from storage.
  922. *
  923. * This method is protected by default in order to keep the public
  924. * api reasonable. You can provide public methods for those you
  925. * actually need in KataoProductFamily.
  926. */
  927. public function getKataoProductsJoinKataoSupplier($criteria = null, $con = null)
  928. {
  929. // include the Peer class
  930. if ($criteria === null) {
  931. $criteria = new Criteria();
  932. }
  933. elseif ($criteria instanceof Criteria)
  934. {
  935. $criteria = clone $criteria;
  936. }
  937. if ($this->collKataoProducts === null) {
  938. if ($this->isNew()) {
  939. $this->collKataoProducts = array();
  940. } else {
  941. $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->getId());
  942. $this->collKataoProducts = KataoProductPeer::doSelectJoinKataoSupplier($criteria, $con);
  943. }
  944. } else {
  945. // the following code is to determine if a new query is
  946. // called for. If the criteria is the same as the last
  947. // one, just return the collection.
  948. $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->getId());
  949. if (!isset($this->lastKataoProductCriteria) || !$this->lastKataoProductCriteria->equals($criteria)) {
  950. $this->collKataoProducts = KataoProductPeer::doSelectJoinKataoSupplier($criteria, $con);
  951. }
  952. }
  953. $this->lastKataoProductCriteria = $criteria;
  954. return $this->collKataoProducts;
  955. }
  956. public function __call($method, $arguments)
  957. {
  958. if (!$callable = sfMixer::getCallable('BaseKataoProductFamily:'.$method))
  959. {
  960. throw new sfException(sprintf('Call to undefined method BaseKataoProductFamily::%s', $method));
  961. }
  962. array_unshift($arguments, $this);
  963. return call_user_func_array($callable, $arguments);
  964. }
  965. } // BaseKataoProductFamily