예제 #1
0
 public function switchType()
 {
     $db = JFactory::getDBO();
     $oldtype = $this->coupon->type;
     // Duplicate Coupon at other table
     $coupon = new coupon(!$oldtype);
     $coupon->createNew($this->coupon->coupon_code, $this->coupon->created_date);
     // Switch id over to new table max
     $oldid = $this->coupon->id;
     $this->coupon->delete();
     $this->coupon = $coupon;
     // Migrate usage entries
     $query = 'UPDATE #__acctexp_couponsxuser' . ' SET `coupon_id` = \'' . $this->coupon->id . '\', `coupon_type` = \'' . $this->coupon->type . '\'' . ' WHERE `coupon_id` = \'' . $oldid . '\' AND `coupon_type` = \'' . $oldtype . '\'';
     $db->setQuery($query);
     $db->query();
 }