Example #1
0
 public function save(Coupon $coupon)
 {
     $data = $coupon->getRawData();
     if ($coupon->getCouponId() > 0) {
         $id = $coupon->getCouponId();
         $this->tableGateway->update($data, array('aufri_coupons_id' => $id));
     } else {
         if (!$this->tableGateway->insert($data)) {
             throw new \Exception("Could not new row {$id}");
         }
         $id = (int) $this->tableGateway->lastInsertValue;
     }
     return $this->getOne(array('aufri_coupons_id' => $id));
 }