BaseKataoCartProduct.php 49 KB

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