BaseKataoCart.php 45 KB

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