I would like to use codeigniter syntax to increase a row value.
$count = 1 ;
$this->db->where('id',$coupon->parent);
$this->db->set('current_users', 'current_users + '.$count, FALSE);
$this->db->update('coupons');
but this code increase current_users
field amount to 2.
ex:
if current_users
be 10 my code increase it to 12 instead of 11 !
Try using this
$count = 1 ;
$this->db->where('id',$coupon->parent);
$this->db->set('current_users', "current_users + $count", FALSE);
$this->db->update('coupons');
Try after changing this line
$this->db->set('current_users', 'current_users + '.$count, FALSE);
To
$this->db->set('current_users', "`current_users` + $count", FALSE);
$count = 1 ;
$this->db->where('id',$coupon->parent);
$this->db->set('current_users', 'current_users+'.$count, FALSE);
$this->db->update('coupons');
static :
$this->db->set('current_users', 'current_users+1', FALSE);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.