BaseKataoOrderProduct.php 55 KB

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