BaseKataoProductCategory.php 35 KB

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