I was going to ask a similar question a little differently, but the problem was the same: I needed to update the date with an interval ( expiry_date = expiry_date + interval 3 month ) and Phil Sturgeon's answer helped solve the problem.
However, I realized that you can still use an array for fields that may have quotation marks, which means you can write:
$this->db->set('received_qty', 'received_qty + 1', FALSE); $this->db->set('expired_date', 'CURDATE() + INTERVAL 10 DAY', FALSE); //extra example 1 $update['received_date'] = date("Ymd"); $update['receiver'] = $receiver_name; //extra example 2 $this->db->where($where); $this->db->update('vrs_distribution', $update);
Where $this->db->last_query() will be output:
UPDATE `vrs_distribution` SET `received_qty` = received_qty + 1, `expiry_date` = CURDATE() + INTERVAL 10 DAY,
Note that fields that use set() do not contain quotation marks and appear first. The rest of the request has the opposite steps (allowing CodeIgniter to protect the remaining fields ").
Armfoot Jul 01 '15 at 15:08 2015-07-01 15:08
source share