BaseKataoCartProduct.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833
  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 int
  60. */
  61. protected $quantity = 1;
  62. /**
  63. * The value for the quantity_adjusted field.
  64. * @var int
  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 int
  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 int
  202. */
  203. public function getQuantity()
  204. {
  205. return $this->quantity;
  206. }
  207. /**
  208. * Get the [quantity_adjusted] column value.
  209. *
  210. * @return int
  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 int
  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 int $v new value
  440. * @return void
  441. */
  442. public function setQuantity($v)
  443. {
  444. // Since the native PHP type for this column is integer,
  445. // we will cast the input value to an int (if it is not).
  446. if ($v !== null && !is_int($v) && is_numeric($v)) {
  447. $v = (int) $v;
  448. }
  449. if ($this->quantity !== $v || $v === 1) {
  450. $this->quantity = $v;
  451. $this->modifiedColumns[] = KataoCartProductPeer::QUANTITY;
  452. }
  453. } // setQuantity()
  454. /**
  455. * Set the value of [quantity_adjusted] column.
  456. *
  457. * @param int $v new value
  458. * @return void
  459. */
  460. public function setQuantityAdjusted($v)
  461. {
  462. // Since the native PHP type for this column is integer,
  463. // we will cast the input value to an int (if it is not).
  464. if ($v !== null && !is_int($v) && is_numeric($v)) {
  465. $v = (int) $v;
  466. }
  467. if ($this->quantity_adjusted !== $v || $v === 0) {
  468. $this->quantity_adjusted = $v;
  469. $this->modifiedColumns[] = KataoCartProductPeer::QUANTITY_ADJUSTED;
  470. }
  471. } // setQuantityAdjusted()
  472. /**
  473. * Set the value of [has_been_adjusted] column.
  474. *
  475. * @param int $v new value
  476. * @return void
  477. */
  478. public function setHasBeenAdjusted($v)
  479. {
  480. // Since the native PHP type for this column is integer,
  481. // we will cast the input value to an int (if it is not).
  482. if ($v !== null && !is_int($v) && is_numeric($v)) {
  483. $v = (int) $v;
  484. }
  485. if ($this->has_been_adjusted !== $v || $v === 0) {
  486. $this->has_been_adjusted = $v;
  487. $this->modifiedColumns[] = KataoCartProductPeer::HAS_BEEN_ADJUSTED;
  488. }
  489. } // setHasBeenAdjusted()
  490. /**
  491. * Set the value of [quantity_delivered] column.
  492. *
  493. * @param int $v new value
  494. * @return void
  495. */
  496. public function setQuantityDelivered($v)
  497. {
  498. // Since the native PHP type for this column is integer,
  499. // we will cast the input value to an int (if it is not).
  500. if ($v !== null && !is_int($v) && is_numeric($v)) {
  501. $v = (int) $v;
  502. }
  503. if ($this->quantity_delivered !== $v || $v === 0) {
  504. $this->quantity_delivered = $v;
  505. $this->modifiedColumns[] = KataoCartProductPeer::QUANTITY_DELIVERED;
  506. }
  507. } // setQuantityDelivered()
  508. /**
  509. * Set the value of [katao_order_product_id] column.
  510. *
  511. * @param int $v new value
  512. * @return void
  513. */
  514. public function setKataoOrderProductId($v)
  515. {
  516. // Since the native PHP type for this column is integer,
  517. // we will cast the input value to an int (if it is not).
  518. if ($v !== null && !is_int($v) && is_numeric($v)) {
  519. $v = (int) $v;
  520. }
  521. if ($this->katao_order_product_id !== $v) {
  522. $this->katao_order_product_id = $v;
  523. $this->modifiedColumns[] = KataoCartProductPeer::KATAO_ORDER_PRODUCT_ID;
  524. }
  525. if ($this->aKataoOrderProduct !== null && $this->aKataoOrderProduct->getId() !== $v) {
  526. $this->aKataoOrderProduct = null;
  527. }
  528. } // setKataoOrderProductId()
  529. /**
  530. * Set the value of [created_at] column.
  531. *
  532. * @param int $v new value
  533. * @return void
  534. */
  535. public function setCreatedAt($v)
  536. {
  537. if ($v !== null && !is_int($v)) {
  538. $ts = strtotime($v);
  539. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  540. throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
  541. }
  542. } else {
  543. $ts = $v;
  544. }
  545. if ($this->created_at !== $ts) {
  546. $this->created_at = $ts;
  547. $this->modifiedColumns[] = KataoCartProductPeer::CREATED_AT;
  548. }
  549. } // setCreatedAt()
  550. /**
  551. * Set the value of [updated_at] column.
  552. *
  553. * @param int $v new value
  554. * @return void
  555. */
  556. public function setUpdatedAt($v)
  557. {
  558. if ($v !== null && !is_int($v)) {
  559. $ts = strtotime($v);
  560. if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE
  561. throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
  562. }
  563. } else {
  564. $ts = $v;
  565. }
  566. if ($this->updated_at !== $ts) {
  567. $this->updated_at = $ts;
  568. $this->modifiedColumns[] = KataoCartProductPeer::UPDATED_AT;
  569. }
  570. } // setUpdatedAt()
  571. /**
  572. * Hydrates (populates) the object variables with values from the database resultset.
  573. *
  574. * An offset (1-based "start column") is specified so that objects can be hydrated
  575. * with a subset of the columns in the resultset rows. This is needed, for example,
  576. * for results of JOIN queries where the resultset row includes columns from two or
  577. * more tables.
  578. *
  579. * @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
  580. * @param int $startcol 1-based offset column which indicates which restultset column to start with.
  581. * @return int next starting column
  582. * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
  583. */
  584. public function hydrate(ResultSet $rs, $startcol = 1)
  585. {
  586. try {
  587. $this->id = $rs->getInt($startcol + 0);
  588. $this->katao_cart_id = $rs->getInt($startcol + 1);
  589. $this->katao_product_id = $rs->getInt($startcol + 2);
  590. $this->product_reference = $rs->getString($startcol + 3);
  591. $this->product_name = $rs->getString($startcol + 4);
  592. $this->product_price_euro = $rs->getFloat($startcol + 5);
  593. $this->product_margin = $rs->getFloat($startcol + 6);
  594. $this->product_tva_rate = $rs->getFloat($startcol + 7);
  595. $this->quantity = $rs->getInt($startcol + 8);
  596. $this->quantity_adjusted = $rs->getInt($startcol + 9);
  597. $this->has_been_adjusted = $rs->getInt($startcol + 10);
  598. $this->quantity_delivered = $rs->getInt($startcol + 11);
  599. $this->katao_order_product_id = $rs->getInt($startcol + 12);
  600. $this->created_at = $rs->getTimestamp($startcol + 13, null);
  601. $this->updated_at = $rs->getTimestamp($startcol + 14, null);
  602. $this->resetModified();
  603. $this->setNew(false);
  604. // FIXME - using NUM_COLUMNS may be clearer.
  605. return $startcol + 15; // 15 = KataoCartProductPeer::NUM_COLUMNS - KataoCartProductPeer::NUM_LAZY_LOAD_COLUMNS).
  606. } catch (Exception $e) {
  607. throw new PropelException("Error populating KataoCartProduct object", $e);
  608. }
  609. }
  610. /**
  611. * Removes this object from datastore and sets delete attribute.
  612. *
  613. * @param Connection $con
  614. * @return void
  615. * @throws PropelException
  616. * @see BaseObject::setDeleted()
  617. * @see BaseObject::isDeleted()
  618. */
  619. public function delete($con = null)
  620. {
  621. foreach (sfMixer::getCallables('BaseKataoCartProduct:delete:pre') as $callable)
  622. {
  623. $ret = call_user_func($callable, $this, $con);
  624. if ($ret)
  625. {
  626. return;
  627. }
  628. }
  629. if ($this->isDeleted()) {
  630. throw new PropelException("This object has already been deleted.");
  631. }
  632. if ($con === null) {
  633. $con = Propel::getConnection(KataoCartProductPeer::DATABASE_NAME);
  634. }
  635. try {
  636. $con->begin();
  637. KataoCartProductPeer::doDelete($this, $con);
  638. $this->setDeleted(true);
  639. $con->commit();
  640. } catch (PropelException $e) {
  641. $con->rollback();
  642. throw $e;
  643. }
  644. foreach (sfMixer::getCallables('BaseKataoCartProduct:delete:post') as $callable)
  645. {
  646. call_user_func($callable, $this, $con);
  647. }
  648. }
  649. /**
  650. * Stores the object in the database. If the object is new,
  651. * it inserts it; otherwise an update is performed. This method
  652. * wraps the doSave() worker method in a transaction.
  653. *
  654. * @param Connection $con
  655. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  656. * @throws PropelException
  657. * @see doSave()
  658. */
  659. public function save($con = null)
  660. {
  661. foreach (sfMixer::getCallables('BaseKataoCartProduct:save:pre') as $callable)
  662. {
  663. $affectedRows = call_user_func($callable, $this, $con);
  664. if (is_int($affectedRows))
  665. {
  666. return $affectedRows;
  667. }
  668. }
  669. if ($this->isNew() && !$this->isColumnModified(KataoCartProductPeer::CREATED_AT))
  670. {
  671. $this->setCreatedAt(time());
  672. }
  673. if ($this->isModified() && !$this->isColumnModified(KataoCartProductPeer::UPDATED_AT))
  674. {
  675. $this->setUpdatedAt(time());
  676. }
  677. if ($this->isDeleted()) {
  678. throw new PropelException("You cannot save an object that has been deleted.");
  679. }
  680. if ($con === null) {
  681. $con = Propel::getConnection(KataoCartProductPeer::DATABASE_NAME);
  682. }
  683. try {
  684. $con->begin();
  685. $affectedRows = $this->doSave($con);
  686. $con->commit();
  687. foreach (sfMixer::getCallables('BaseKataoCartProduct:save:post') as $callable)
  688. {
  689. call_user_func($callable, $this, $con, $affectedRows);
  690. }
  691. return $affectedRows;
  692. } catch (PropelException $e) {
  693. $con->rollback();
  694. throw $e;
  695. }
  696. }
  697. /**
  698. * Stores the object in the database.
  699. *
  700. * If the object is new, it inserts it; otherwise an update is performed.
  701. * All related objects are also updated in this method.
  702. *
  703. * @param Connection $con
  704. * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  705. * @throws PropelException
  706. * @see save()
  707. */
  708. protected function doSave($con)
  709. {
  710. $affectedRows = 0; // initialize var to track total num of affected rows
  711. if (!$this->alreadyInSave) {
  712. $this->alreadyInSave = true;
  713. // We call the save method on the following object(s) if they
  714. // were passed to this object by their coresponding set
  715. // method. This object relates to these object(s) by a
  716. // foreign key reference.
  717. if ($this->aKataoCart !== null) {
  718. if ($this->aKataoCart->isModified()) {
  719. $affectedRows += $this->aKataoCart->save($con);
  720. }
  721. $this->setKataoCart($this->aKataoCart);
  722. }
  723. if ($this->aKataoProduct !== null) {
  724. if ($this->aKataoProduct->isModified()) {
  725. $affectedRows += $this->aKataoProduct->save($con);
  726. }
  727. $this->setKataoProduct($this->aKataoProduct);
  728. }
  729. if ($this->aKataoOrderProduct !== null) {
  730. if ($this->aKataoOrderProduct->isModified()) {
  731. $affectedRows += $this->aKataoOrderProduct->save($con);
  732. }
  733. $this->setKataoOrderProduct($this->aKataoOrderProduct);
  734. }
  735. // If this object has been modified, then save it to the database.
  736. if ($this->isModified()) {
  737. if ($this->isNew()) {
  738. $pk = KataoCartProductPeer::doInsert($this, $con);
  739. $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
  740. // should always be true here (even though technically
  741. // BasePeer::doInsert() can insert multiple rows).
  742. $this->setId($pk); //[IMV] update autoincrement primary key
  743. $this->setNew(false);
  744. } else {
  745. $affectedRows += KataoCartProductPeer::doUpdate($this, $con);
  746. }
  747. $this->resetModified(); // [HL] After being saved an object is no longer 'modified'
  748. }
  749. if ($this->collKataoInvoiceProducts !== null) {
  750. foreach($this->collKataoInvoiceProducts as $referrerFK) {
  751. if (!$referrerFK->isDeleted()) {
  752. $affectedRows += $referrerFK->save($con);
  753. }
  754. }
  755. }
  756. $this->alreadyInSave = false;
  757. }
  758. return $affectedRows;
  759. } // doSave()
  760. /**
  761. * Array of ValidationFailed objects.
  762. * @var array ValidationFailed[]
  763. */
  764. protected $validationFailures = array();
  765. /**
  766. * Gets any ValidationFailed objects that resulted from last call to validate().
  767. *
  768. *
  769. * @return array ValidationFailed[]
  770. * @see validate()
  771. */
  772. public function getValidationFailures()
  773. {
  774. return $this->validationFailures;
  775. }
  776. /**
  777. * Validates the objects modified field values and all objects related to this table.
  778. *
  779. * If $columns is either a column name or an array of column names
  780. * only those columns are validated.
  781. *
  782. * @param mixed $columns Column name or an array of column names.
  783. * @return boolean Whether all columns pass validation.
  784. * @see doValidate()
  785. * @see getValidationFailures()
  786. */
  787. public function validate($columns = null)
  788. {
  789. $res = $this->doValidate($columns);
  790. if ($res === true) {
  791. $this->validationFailures = array();
  792. return true;
  793. } else {
  794. $this->validationFailures = $res;
  795. return false;
  796. }
  797. }
  798. /**
  799. * This function performs the validation work for complex object models.
  800. *
  801. * In addition to checking the current object, all related objects will
  802. * also be validated. If all pass then <code>true</code> is returned; otherwise
  803. * an aggreagated array of ValidationFailed objects will be returned.
  804. *
  805. * @param array $columns Array of column names to validate.
  806. * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  807. */
  808. protected function doValidate($columns = null)
  809. {
  810. if (!$this->alreadyInValidation) {
  811. $this->alreadyInValidation = true;
  812. $retval = null;
  813. $failureMap = array();
  814. // We call the validate method on the following object(s) if they
  815. // were passed to this object by their coresponding set
  816. // method. This object relates to these object(s) by a
  817. // foreign key reference.
  818. if ($this->aKataoCart !== null) {
  819. if (!$this->aKataoCart->validate($columns)) {
  820. $failureMap = array_merge($failureMap, $this->aKataoCart->getValidationFailures());
  821. }
  822. }
  823. if ($this->aKataoProduct !== null) {
  824. if (!$this->aKataoProduct->validate($columns)) {
  825. $failureMap = array_merge($failureMap, $this->aKataoProduct->getValidationFailures());
  826. }
  827. }
  828. if ($this->aKataoOrderProduct !== null) {
  829. if (!$this->aKataoOrderProduct->validate($columns)) {
  830. $failureMap = array_merge($failureMap, $this->aKataoOrderProduct->getValidationFailures());
  831. }
  832. }
  833. if (($retval = KataoCartProductPeer::doValidate($this, $columns)) !== true) {
  834. $failureMap = array_merge($failureMap, $retval);
  835. }
  836. if ($this->collKataoInvoiceProducts !== null) {
  837. foreach($this->collKataoInvoiceProducts as $referrerFK) {
  838. if (!$referrerFK->validate($columns)) {
  839. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  840. }
  841. }
  842. }
  843. $this->alreadyInValidation = false;
  844. }
  845. return (!empty($failureMap) ? $failureMap : true);
  846. }
  847. /**
  848. * Retrieves a field from the object by name passed in as a string.
  849. *
  850. * @param string $name name
  851. * @param string $type The type of fieldname the $name is of:
  852. * one of the class type constants TYPE_PHPNAME,
  853. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  854. * @return mixed Value of field.
  855. */
  856. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  857. {
  858. $pos = KataoCartProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  859. return $this->getByPosition($pos);
  860. }
  861. /**
  862. * Retrieves a field from the object by Position as specified in the xml schema.
  863. * Zero-based.
  864. *
  865. * @param int $pos position in xml schema
  866. * @return mixed Value of field at $pos
  867. */
  868. public function getByPosition($pos)
  869. {
  870. switch($pos) {
  871. case 0:
  872. return $this->getId();
  873. break;
  874. case 1:
  875. return $this->getKataoCartId();
  876. break;
  877. case 2:
  878. return $this->getKataoProductId();
  879. break;
  880. case 3:
  881. return $this->getProductReference();
  882. break;
  883. case 4:
  884. return $this->getProductName();
  885. break;
  886. case 5:
  887. return $this->getProductPriceEuro();
  888. break;
  889. case 6:
  890. return $this->getProductMargin();
  891. break;
  892. case 7:
  893. return $this->getProductTvaRate();
  894. break;
  895. case 8:
  896. return $this->getQuantity();
  897. break;
  898. case 9:
  899. return $this->getQuantityAdjusted();
  900. break;
  901. case 10:
  902. return $this->getHasBeenAdjusted();
  903. break;
  904. case 11:
  905. return $this->getQuantityDelivered();
  906. break;
  907. case 12:
  908. return $this->getKataoOrderProductId();
  909. break;
  910. case 13:
  911. return $this->getCreatedAt();
  912. break;
  913. case 14:
  914. return $this->getUpdatedAt();
  915. break;
  916. default:
  917. return null;
  918. break;
  919. } // switch()
  920. }
  921. /**
  922. * Exports the object as an array.
  923. *
  924. * You can specify the key type of the array by passing one of the class
  925. * type constants.
  926. *
  927. * @param string $keyType One of the class type constants TYPE_PHPNAME,
  928. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  929. * @return an associative array containing the field names (as keys) and field values
  930. */
  931. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  932. {
  933. $keys = KataoCartProductPeer::getFieldNames($keyType);
  934. $result = array(
  935. $keys[0] => $this->getId(),
  936. $keys[1] => $this->getKataoCartId(),
  937. $keys[2] => $this->getKataoProductId(),
  938. $keys[3] => $this->getProductReference(),
  939. $keys[4] => $this->getProductName(),
  940. $keys[5] => $this->getProductPriceEuro(),
  941. $keys[6] => $this->getProductMargin(),
  942. $keys[7] => $this->getProductTvaRate(),
  943. $keys[8] => $this->getQuantity(),
  944. $keys[9] => $this->getQuantityAdjusted(),
  945. $keys[10] => $this->getHasBeenAdjusted(),
  946. $keys[11] => $this->getQuantityDelivered(),
  947. $keys[12] => $this->getKataoOrderProductId(),
  948. $keys[13] => $this->getCreatedAt(),
  949. $keys[14] => $this->getUpdatedAt(),
  950. );
  951. return $result;
  952. }
  953. /**
  954. * Sets a field from the object by name passed in as a string.
  955. *
  956. * @param string $name peer name
  957. * @param mixed $value field value
  958. * @param string $type The type of fieldname the $name is of:
  959. * one of the class type constants TYPE_PHPNAME,
  960. * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
  961. * @return void
  962. */
  963. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  964. {
  965. $pos = KataoCartProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  966. return $this->setByPosition($pos, $value);
  967. }
  968. /**
  969. * Sets a field from the object by Position as specified in the xml schema.
  970. * Zero-based.
  971. *
  972. * @param int $pos position in xml schema
  973. * @param mixed $value field value
  974. * @return void
  975. */
  976. public function setByPosition($pos, $value)
  977. {
  978. switch($pos) {
  979. case 0:
  980. $this->setId($value);
  981. break;
  982. case 1:
  983. $this->setKataoCartId($value);
  984. break;
  985. case 2:
  986. $this->setKataoProductId($value);
  987. break;
  988. case 3:
  989. $this->setProductReference($value);
  990. break;
  991. case 4:
  992. $this->setProductName($value);
  993. break;
  994. case 5:
  995. $this->setProductPriceEuro($value);
  996. break;
  997. case 6:
  998. $this->setProductMargin($value);
  999. break;
  1000. case 7:
  1001. $this->setProductTvaRate($value);
  1002. break;
  1003. case 8:
  1004. $this->setQuantity($value);
  1005. break;
  1006. case 9:
  1007. $this->setQuantityAdjusted($value);
  1008. break;
  1009. case 10:
  1010. $this->setHasBeenAdjusted($value);
  1011. break;
  1012. case 11:
  1013. $this->setQuantityDelivered($value);
  1014. break;
  1015. case 12:
  1016. $this->setKataoOrderProductId($value);
  1017. break;
  1018. case 13:
  1019. $this->setCreatedAt($value);
  1020. break;
  1021. case 14:
  1022. $this->setUpdatedAt($value);
  1023. break;
  1024. } // switch()
  1025. }
  1026. /**
  1027. * Populates the object using an array.
  1028. *
  1029. * This is particularly useful when populating an object from one of the
  1030. * request arrays (e.g. $_POST). This method goes through the column
  1031. * names, checking to see whether a matching key exists in populated
  1032. * array. If so the setByName() method is called for that column.
  1033. *
  1034. * You can specify the key type of the array by additionally passing one
  1035. * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  1036. * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  1037. *
  1038. * @param array $arr An array to populate the object from.
  1039. * @param string $keyType The type of keys the array uses.
  1040. * @return void
  1041. */
  1042. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  1043. {
  1044. $keys = KataoCartProductPeer::getFieldNames($keyType);
  1045. if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
  1046. if (array_key_exists($keys[1], $arr)) $this->setKataoCartId($arr[$keys[1]]);
  1047. if (array_key_exists($keys[2], $arr)) $this->setKataoProductId($arr[$keys[2]]);
  1048. if (array_key_exists($keys[3], $arr)) $this->setProductReference($arr[$keys[3]]);
  1049. if (array_key_exists($keys[4], $arr)) $this->setProductName($arr[$keys[4]]);
  1050. if (array_key_exists($keys[5], $arr)) $this->setProductPriceEuro($arr[$keys[5]]);
  1051. if (array_key_exists($keys[6], $arr)) $this->setProductMargin($arr[$keys[6]]);
  1052. if (array_key_exists($keys[7], $arr)) $this->setProductTvaRate($arr[$keys[7]]);
  1053. if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]);
  1054. if (array_key_exists($keys[9], $arr)) $this->setQuantityAdjusted($arr[$keys[9]]);
  1055. if (array_key_exists($keys[10], $arr)) $this->setHasBeenAdjusted($arr[$keys[10]]);
  1056. if (array_key_exists($keys[11], $arr)) $this->setQuantityDelivered($arr[$keys[11]]);
  1057. if (array_key_exists($keys[12], $arr)) $this->setKataoOrderProductId($arr[$keys[12]]);
  1058. if (array_key_exists($keys[13], $arr)) $this->setCreatedAt($arr[$keys[13]]);
  1059. if (array_key_exists($keys[14], $arr)) $this->setUpdatedAt($arr[$keys[14]]);
  1060. }
  1061. /**
  1062. * Build a Criteria object containing the values of all modified columns in this object.
  1063. *
  1064. * @return Criteria The Criteria object containing all modified values.
  1065. */
  1066. public function buildCriteria()
  1067. {
  1068. $criteria = new Criteria(KataoCartProductPeer::DATABASE_NAME);
  1069. if ($this->isColumnModified(KataoCartProductPeer::ID)) $criteria->add(KataoCartProductPeer::ID, $this->id);
  1070. if ($this->isColumnModified(KataoCartProductPeer::KATAO_CART_ID)) $criteria->add(KataoCartProductPeer::KATAO_CART_ID, $this->katao_cart_id);
  1071. if ($this->isColumnModified(KataoCartProductPeer::KATAO_PRODUCT_ID)) $criteria->add(KataoCartProductPeer::KATAO_PRODUCT_ID, $this->katao_product_id);
  1072. if ($this->isColumnModified(KataoCartProductPeer::PRODUCT_REFERENCE)) $criteria->add(KataoCartProductPeer::PRODUCT_REFERENCE, $this->product_reference);
  1073. if ($this->isColumnModified(KataoCartProductPeer::PRODUCT_NAME)) $criteria->add(KataoCartProductPeer::PRODUCT_NAME, $this->product_name);
  1074. if ($this->isColumnModified(KataoCartProductPeer::PRODUCT_PRICE_EURO)) $criteria->add(KataoCartProductPeer::PRODUCT_PRICE_EURO, $this->product_price_euro);
  1075. if ($this->isColumnModified(KataoCartProductPeer::PRODUCT_MARGIN)) $criteria->add(KataoCartProductPeer::PRODUCT_MARGIN, $this->product_margin);
  1076. if ($this->isColumnModified(KataoCartProductPeer::PRODUCT_TVA_RATE)) $criteria->add(KataoCartProductPeer::PRODUCT_TVA_RATE, $this->product_tva_rate);
  1077. if ($this->isColumnModified(KataoCartProductPeer::QUANTITY)) $criteria->add(KataoCartProductPeer::QUANTITY, $this->quantity);
  1078. if ($this->isColumnModified(KataoCartProductPeer::QUANTITY_ADJUSTED)) $criteria->add(KataoCartProductPeer::QUANTITY_ADJUSTED, $this->quantity_adjusted);
  1079. if ($this->isColumnModified(KataoCartProductPeer::HAS_BEEN_ADJUSTED)) $criteria->add(KataoCartProductPeer::HAS_BEEN_ADJUSTED, $this->has_been_adjusted);
  1080. if ($this->isColumnModified(KataoCartProductPeer::QUANTITY_DELIVERED)) $criteria->add(KataoCartProductPeer::QUANTITY_DELIVERED, $this->quantity_delivered);
  1081. if ($this->isColumnModified(KataoCartProductPeer::KATAO_ORDER_PRODUCT_ID)) $criteria->add(KataoCartProductPeer::KATAO_ORDER_PRODUCT_ID, $this->katao_order_product_id);
  1082. if ($this->isColumnModified(KataoCartProductPeer::CREATED_AT)) $criteria->add(KataoCartProductPeer::CREATED_AT, $this->created_at);
  1083. if ($this->isColumnModified(KataoCartProductPeer::UPDATED_AT)) $criteria->add(KataoCartProductPeer::UPDATED_AT, $this->updated_at);
  1084. return $criteria;
  1085. }
  1086. /**
  1087. * Builds a Criteria object containing the primary key for this object.
  1088. *
  1089. * Unlike buildCriteria() this method includes the primary key values regardless
  1090. * of whether or not they have been modified.
  1091. *
  1092. * @return Criteria The Criteria object containing value(s) for primary key(s).
  1093. */
  1094. public function buildPkeyCriteria()
  1095. {
  1096. $criteria = new Criteria(KataoCartProductPeer::DATABASE_NAME);
  1097. $criteria->add(KataoCartProductPeer::ID, $this->id);
  1098. return $criteria;
  1099. }
  1100. /**
  1101. * Returns the primary key for this object (row).
  1102. * @return int
  1103. */
  1104. public function getPrimaryKey()
  1105. {
  1106. return $this->getId();
  1107. }
  1108. /**
  1109. * Generic method to set the primary key (id column).
  1110. *
  1111. * @param int $key Primary key.
  1112. * @return void
  1113. */
  1114. public function setPrimaryKey($key)
  1115. {
  1116. $this->setId($key);
  1117. }
  1118. /**
  1119. * Sets contents of passed object to values from current object.
  1120. *
  1121. * If desired, this method can also make copies of all associated (fkey referrers)
  1122. * objects.
  1123. *
  1124. * @param object $copyObj An object of KataoCartProduct (or compatible) type.
  1125. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1126. * @throws PropelException
  1127. */
  1128. public function copyInto($copyObj, $deepCopy = false)
  1129. {
  1130. $copyObj->setKataoCartId($this->katao_cart_id);
  1131. $copyObj->setKataoProductId($this->katao_product_id);
  1132. $copyObj->setProductReference($this->product_reference);
  1133. $copyObj->setProductName($this->product_name);
  1134. $copyObj->setProductPriceEuro($this->product_price_euro);
  1135. $copyObj->setProductMargin($this->product_margin);
  1136. $copyObj->setProductTvaRate($this->product_tva_rate);
  1137. $copyObj->setQuantity($this->quantity);
  1138. $copyObj->setQuantityAdjusted($this->quantity_adjusted);
  1139. $copyObj->setHasBeenAdjusted($this->has_been_adjusted);
  1140. $copyObj->setQuantityDelivered($this->quantity_delivered);
  1141. $copyObj->setKataoOrderProductId($this->katao_order_product_id);
  1142. $copyObj->setCreatedAt($this->created_at);
  1143. $copyObj->setUpdatedAt($this->updated_at);
  1144. if ($deepCopy) {
  1145. // important: temporarily setNew(false) because this affects the behavior of
  1146. // the getter/setter methods for fkey referrer objects.
  1147. $copyObj->setNew(false);
  1148. foreach($this->getKataoInvoiceProducts() as $relObj) {
  1149. $copyObj->addKataoInvoiceProduct($relObj->copy($deepCopy));
  1150. }
  1151. } // if ($deepCopy)
  1152. $copyObj->setNew(true);
  1153. $copyObj->setId(NULL); // this is a pkey column, so set to default value
  1154. }
  1155. /**
  1156. * Makes a copy of this object that will be inserted as a new row in table when saved.
  1157. * It creates a new object filling in the simple attributes, but skipping any primary
  1158. * keys that are defined for the table.
  1159. *
  1160. * If desired, this method can also make copies of all associated (fkey referrers)
  1161. * objects.
  1162. *
  1163. * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
  1164. * @return KataoCartProduct Clone of current object.
  1165. * @throws PropelException
  1166. */
  1167. public function copy($deepCopy = false)
  1168. {
  1169. // we use get_class(), because this might be a subclass
  1170. $clazz = get_class($this);
  1171. $copyObj = new $clazz();
  1172. $this->copyInto($copyObj, $deepCopy);
  1173. return $copyObj;
  1174. }
  1175. /**
  1176. * Returns a peer instance associated with this om.
  1177. *
  1178. * Since Peer classes are not to have any instance attributes, this method returns the
  1179. * same instance for all member of this class. The method could therefore
  1180. * be static, but this would prevent one from overriding the behavior.
  1181. *
  1182. * @return KataoCartProductPeer
  1183. */
  1184. public function getPeer()
  1185. {
  1186. if (self::$peer === null) {
  1187. self::$peer = new KataoCartProductPeer();
  1188. }
  1189. return self::$peer;
  1190. }
  1191. /**
  1192. * Declares an association between this object and a KataoCart object.
  1193. *
  1194. * @param KataoCart $v
  1195. * @return void
  1196. * @throws PropelException
  1197. */
  1198. public function setKataoCart($v)
  1199. {
  1200. if ($v === null) {
  1201. $this->setKataoCartId(NULL);
  1202. } else {
  1203. $this->setKataoCartId($v->getId());
  1204. }
  1205. $this->aKataoCart = $v;
  1206. }
  1207. /**
  1208. * Get the associated KataoCart object
  1209. *
  1210. * @param Connection Optional Connection object.
  1211. * @return KataoCart The associated KataoCart object.
  1212. * @throws PropelException
  1213. */
  1214. public function getKataoCart($con = null)
  1215. {
  1216. if ($this->aKataoCart === null && ($this->katao_cart_id !== null)) {
  1217. // include the related Peer class
  1218. $this->aKataoCart = KataoCartPeer::retrieveByPK($this->katao_cart_id, $con);
  1219. /* The following can be used instead of the line above to
  1220. guarantee the related object contains a reference
  1221. to this object, but this level of coupling
  1222. may be undesirable in many circumstances.
  1223. As it can lead to a db query with many results that may
  1224. never be used.
  1225. $obj = KataoCartPeer::retrieveByPK($this->katao_cart_id, $con);
  1226. $obj->addKataoCarts($this);
  1227. */
  1228. }
  1229. return $this->aKataoCart;
  1230. }
  1231. /**
  1232. * Declares an association between this object and a KataoProduct object.
  1233. *
  1234. * @param KataoProduct $v
  1235. * @return void
  1236. * @throws PropelException
  1237. */
  1238. public function setKataoProduct($v)
  1239. {
  1240. if ($v === null) {
  1241. $this->setKataoProductId(NULL);
  1242. } else {
  1243. $this->setKataoProductId($v->getId());
  1244. }
  1245. $this->aKataoProduct = $v;
  1246. }
  1247. /**
  1248. * Get the associated KataoProduct object
  1249. *
  1250. * @param Connection Optional Connection object.
  1251. * @return KataoProduct The associated KataoProduct object.
  1252. * @throws PropelException
  1253. */
  1254. public function getKataoProduct($con = null)
  1255. {
  1256. if ($this->aKataoProduct === null && ($this->katao_product_id !== null)) {
  1257. // include the related Peer class
  1258. $this->aKataoProduct = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1259. /* The following can be used instead of the line above to
  1260. guarantee the related object contains a reference
  1261. to this object, but this level of coupling
  1262. may be undesirable in many circumstances.
  1263. As it can lead to a db query with many results that may
  1264. never be used.
  1265. $obj = KataoProductPeer::retrieveByPK($this->katao_product_id, $con);
  1266. $obj->addKataoProducts($this);
  1267. */
  1268. }
  1269. return $this->aKataoProduct;
  1270. }
  1271. /**
  1272. * Declares an association between this object and a KataoOrderProduct object.
  1273. *
  1274. * @param KataoOrderProduct $v
  1275. * @return void
  1276. * @throws PropelException
  1277. */
  1278. public function setKataoOrderProduct($v)
  1279. {
  1280. if ($v === null) {
  1281. $this->setKataoOrderProductId(NULL);
  1282. } else {
  1283. $this->setKataoOrderProductId($v->getId());
  1284. }
  1285. $this->aKataoOrderProduct = $v;
  1286. }
  1287. /**
  1288. * Get the associated KataoOrderProduct object
  1289. *
  1290. * @param Connection Optional Connection object.
  1291. * @return KataoOrderProduct The associated KataoOrderProduct object.
  1292. * @throws PropelException
  1293. */
  1294. public function getKataoOrderProduct($con = null)
  1295. {
  1296. if ($this->aKataoOrderProduct === null && ($this->katao_order_product_id !== null)) {
  1297. // include the related Peer class
  1298. $this->aKataoOrderProduct = KataoOrderProductPeer::retrieveByPK($this->katao_order_product_id, $con);
  1299. /* The following can be used instead of the line above to
  1300. guarantee the related object contains a reference
  1301. to this object, but this level of coupling
  1302. may be undesirable in many circumstances.
  1303. As it can lead to a db query with many results that may
  1304. never be used.
  1305. $obj = KataoOrderProductPeer::retrieveByPK($this->katao_order_product_id, $con);
  1306. $obj->addKataoOrderProducts($this);
  1307. */
  1308. }
  1309. return $this->aKataoOrderProduct;
  1310. }
  1311. /**
  1312. * Temporary storage of collKataoInvoiceProducts to save a possible db hit in
  1313. * the event objects are add to the collection, but the
  1314. * complete collection is never requested.
  1315. * @return void
  1316. */
  1317. public function initKataoInvoiceProducts()
  1318. {
  1319. if ($this->collKataoInvoiceProducts === null) {
  1320. $this->collKataoInvoiceProducts = array();
  1321. }
  1322. }
  1323. /**
  1324. * If this collection has already been initialized with
  1325. * an identical criteria, it returns the collection.
  1326. * Otherwise if this KataoCartProduct has previously
  1327. * been saved, it will retrieve related KataoInvoiceProducts from storage.
  1328. * If this KataoCartProduct is new, it will return
  1329. * an empty collection or the current collection, the criteria
  1330. * is ignored on a new object.
  1331. *
  1332. * @param Connection $con
  1333. * @param Criteria $criteria
  1334. * @throws PropelException
  1335. */
  1336. public function getKataoInvoiceProducts($criteria = null, $con = null)
  1337. {
  1338. // include the Peer class
  1339. if ($criteria === null) {
  1340. $criteria = new Criteria();
  1341. }
  1342. elseif ($criteria instanceof Criteria)
  1343. {
  1344. $criteria = clone $criteria;
  1345. }
  1346. if ($this->collKataoInvoiceProducts === null) {
  1347. if ($this->isNew()) {
  1348. $this->collKataoInvoiceProducts = array();
  1349. } else {
  1350. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1351. KataoInvoiceProductPeer::addSelectColumns($criteria);
  1352. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelect($criteria, $con);
  1353. }
  1354. } else {
  1355. // criteria has no effect for a new object
  1356. if (!$this->isNew()) {
  1357. // the following code is to determine if a new query is
  1358. // called for. If the criteria is the same as the last
  1359. // one, just return the collection.
  1360. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1361. KataoInvoiceProductPeer::addSelectColumns($criteria);
  1362. if (!isset($this->lastKataoInvoiceProductCriteria) || !$this->lastKataoInvoiceProductCriteria->equals($criteria)) {
  1363. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelect($criteria, $con);
  1364. }
  1365. }
  1366. }
  1367. $this->lastKataoInvoiceProductCriteria = $criteria;
  1368. return $this->collKataoInvoiceProducts;
  1369. }
  1370. /**
  1371. * Returns the number of related KataoInvoiceProducts.
  1372. *
  1373. * @param Criteria $criteria
  1374. * @param boolean $distinct
  1375. * @param Connection $con
  1376. * @throws PropelException
  1377. */
  1378. public function countKataoInvoiceProducts($criteria = null, $distinct = false, $con = null)
  1379. {
  1380. // include the Peer class
  1381. if ($criteria === null) {
  1382. $criteria = new Criteria();
  1383. }
  1384. elseif ($criteria instanceof Criteria)
  1385. {
  1386. $criteria = clone $criteria;
  1387. }
  1388. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1389. return KataoInvoiceProductPeer::doCount($criteria, $distinct, $con);
  1390. }
  1391. /**
  1392. * Method called to associate a KataoInvoiceProduct object to this object
  1393. * through the KataoInvoiceProduct foreign key attribute
  1394. *
  1395. * @param KataoInvoiceProduct $l KataoInvoiceProduct
  1396. * @return void
  1397. * @throws PropelException
  1398. */
  1399. public function addKataoInvoiceProduct(KataoInvoiceProduct $l)
  1400. {
  1401. $this->collKataoInvoiceProducts[] = $l;
  1402. $l->setKataoCartProduct($this);
  1403. }
  1404. /**
  1405. * If this collection has already been initialized with
  1406. * an identical criteria, it returns the collection.
  1407. * Otherwise if this KataoCartProduct is new, it will return
  1408. * an empty collection; or if this KataoCartProduct has previously
  1409. * been saved, it will retrieve related KataoInvoiceProducts from storage.
  1410. *
  1411. * This method is protected by default in order to keep the public
  1412. * api reasonable. You can provide public methods for those you
  1413. * actually need in KataoCartProduct.
  1414. */
  1415. public function getKataoInvoiceProductsJoinKataoInvoice($criteria = null, $con = null)
  1416. {
  1417. // include the Peer class
  1418. if ($criteria === null) {
  1419. $criteria = new Criteria();
  1420. }
  1421. elseif ($criteria instanceof Criteria)
  1422. {
  1423. $criteria = clone $criteria;
  1424. }
  1425. if ($this->collKataoInvoiceProducts === null) {
  1426. if ($this->isNew()) {
  1427. $this->collKataoInvoiceProducts = array();
  1428. } else {
  1429. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1430. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoInvoice($criteria, $con);
  1431. }
  1432. } else {
  1433. // the following code is to determine if a new query is
  1434. // called for. If the criteria is the same as the last
  1435. // one, just return the collection.
  1436. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1437. if (!isset($this->lastKataoInvoiceProductCriteria) || !$this->lastKataoInvoiceProductCriteria->equals($criteria)) {
  1438. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoInvoice($criteria, $con);
  1439. }
  1440. }
  1441. $this->lastKataoInvoiceProductCriteria = $criteria;
  1442. return $this->collKataoInvoiceProducts;
  1443. }
  1444. /**
  1445. * If this collection has already been initialized with
  1446. * an identical criteria, it returns the collection.
  1447. * Otherwise if this KataoCartProduct is new, it will return
  1448. * an empty collection; or if this KataoCartProduct has previously
  1449. * been saved, it will retrieve related KataoInvoiceProducts from storage.
  1450. *
  1451. * This method is protected by default in order to keep the public
  1452. * api reasonable. You can provide public methods for those you
  1453. * actually need in KataoCartProduct.
  1454. */
  1455. public function getKataoInvoiceProductsJoinKataoProduct($criteria = null, $con = null)
  1456. {
  1457. // include the Peer class
  1458. if ($criteria === null) {
  1459. $criteria = new Criteria();
  1460. }
  1461. elseif ($criteria instanceof Criteria)
  1462. {
  1463. $criteria = clone $criteria;
  1464. }
  1465. if ($this->collKataoInvoiceProducts === null) {
  1466. if ($this->isNew()) {
  1467. $this->collKataoInvoiceProducts = array();
  1468. } else {
  1469. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1470. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoProduct($criteria, $con);
  1471. }
  1472. } else {
  1473. // the following code is to determine if a new query is
  1474. // called for. If the criteria is the same as the last
  1475. // one, just return the collection.
  1476. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1477. if (!isset($this->lastKataoInvoiceProductCriteria) || !$this->lastKataoInvoiceProductCriteria->equals($criteria)) {
  1478. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoProduct($criteria, $con);
  1479. }
  1480. }
  1481. $this->lastKataoInvoiceProductCriteria = $criteria;
  1482. return $this->collKataoInvoiceProducts;
  1483. }
  1484. /**
  1485. * If this collection has already been initialized with
  1486. * an identical criteria, it returns the collection.
  1487. * Otherwise if this KataoCartProduct is new, it will return
  1488. * an empty collection; or if this KataoCartProduct has previously
  1489. * been saved, it will retrieve related KataoInvoiceProducts from storage.
  1490. *
  1491. * This method is protected by default in order to keep the public
  1492. * api reasonable. You can provide public methods for those you
  1493. * actually need in KataoCartProduct.
  1494. */
  1495. public function getKataoInvoiceProductsJoinKataoOrderProduct($criteria = null, $con = null)
  1496. {
  1497. // include the Peer class
  1498. if ($criteria === null) {
  1499. $criteria = new Criteria();
  1500. }
  1501. elseif ($criteria instanceof Criteria)
  1502. {
  1503. $criteria = clone $criteria;
  1504. }
  1505. if ($this->collKataoInvoiceProducts === null) {
  1506. if ($this->isNew()) {
  1507. $this->collKataoInvoiceProducts = array();
  1508. } else {
  1509. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1510. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoOrderProduct($criteria, $con);
  1511. }
  1512. } else {
  1513. // the following code is to determine if a new query is
  1514. // called for. If the criteria is the same as the last
  1515. // one, just return the collection.
  1516. $criteria->add(KataoInvoiceProductPeer::KATAO_CART_PRODUCT_ID, $this->getId());
  1517. if (!isset($this->lastKataoInvoiceProductCriteria) || !$this->lastKataoInvoiceProductCriteria->equals($criteria)) {
  1518. $this->collKataoInvoiceProducts = KataoInvoiceProductPeer::doSelectJoinKataoOrderProduct($criteria, $con);
  1519. }
  1520. }
  1521. $this->lastKataoInvoiceProductCriteria = $criteria;
  1522. return $this->collKataoInvoiceProducts;
  1523. }
  1524. public function __call($method, $arguments)
  1525. {
  1526. if (!$callable = sfMixer::getCallable('BaseKataoCartProduct:'.$method))
  1527. {
  1528. throw new sfException(sprintf('Call to undefined method BaseKataoCartProduct::%s', $method));
  1529. }
  1530. array_unshift($arguments, $this);
  1531. return call_user_func_array($callable, $arguments);
  1532. }
  1533. } // BaseKataoCartProduct