KataoCartProductPeer.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * Subclass for performing query and update operations on the 'katao_cart_product' table.
  4. *
  5. * @package lib.model
  6. */
  7. class KataoCartProductPeer extends BaseKataoCartProductPeer {
  8. /**
  9. * KataoCartProductPeer::retrieveByCartAndProduct()
  10. *
  11. * @param integer $katao_cart_id
  12. * @param integer $katao_product_id
  13. * @return KataoCartProduct
  14. */
  15. public static function retrieveByCartAndProduct($katao_cart_id, $katao_product_id) {
  16. $criteria = new Criteria();
  17. $criteria->add(self::KATAO_CART_ID, $katao_cart_id);
  18. $criteria->add(self::KATAO_PRODUCT_ID, $katao_product_id);
  19. if (null == $return = self::doSelectOne($criteria)) {
  20. $return = new KataoCartProduct();
  21. $return->setKataoCartId($katao_cart_id);
  22. $return->setKataoProductId($katao_product_id);
  23. $return->save();
  24. }
  25. return $return;
  26. }
  27. /**
  28. * KataoCartProductPeer::deleteByCartAndProduct()
  29. *
  30. * @param integer $katao_cart_id
  31. * @param integer $katao_product_id
  32. * @return boolean
  33. */
  34. public static function deleteByCartAndProduct($katao_cart_id, $katao_product_id) {
  35. $criteria = new Criteria();
  36. $criteria->add(self::KATAO_CART_ID, $katao_cart_id);
  37. $criteria->add(self::KATAO_PRODUCT_ID, $katao_product_id);
  38. return self::doDelete($criteria);
  39. }
  40. /**
  41. * KataoCartProductPeer::n()
  42. *
  43. * @param int $id
  44. * @param float $quantity
  45. * @return
  46. */
  47. public static function adjustQuantity($id, $quantity) {
  48. $criteria_update = new Criteria();
  49. $criteria_update->add(self::QUANTITY_ADJUSTED, $quantity);
  50. // $criteria_update->add(self::HAS_BEEN_ADJUSTED, true);
  51. $criteria_where = new Criteria();
  52. $criteria_where->add(self::ID, $id);
  53. BasePeer::doUpdate($criteria_where, $criteria_update, Propel::getConnection());
  54. }
  55. /**
  56. * KataoCartProductPeer::deliverQuantity()
  57. *
  58. * @param int $id
  59. * @param float $quantity
  60. * @return
  61. */
  62. public static function deliverQuantity($id, $quantity) {
  63. $criteria_update = new Criteria();
  64. $criteria_update->add(self::QUANTITY_DELIVERED, $quantity);
  65. $criteria_where = new Criteria();
  66. $criteria_where->add(self::ID, $id);
  67. BasePeer::doUpdate($criteria_where, $criteria_update, Propel::getConnection());
  68. }
  69. }