![]() |
Increment a field in the query builder - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Increment a field in the query builder (/showthread.php?tid=410) |
Increment a field in the query builder - SquallX - 11-30-2014 Hi ! Actually I'm working of the completion of a data interval system and with the query buider it's impossible to do something like that : PHP Code: $this->db->update($table, ['f_right' => 'f_right + 1'], ['f_id' => $id]); We need to do : PHP Code: $sql = "UPDATE " . $table . " SET f_right = f_right + 1 WHERE f_id = " . $this->db->escape($id); Do you think it will be useful to implement a condition to specify the new value is an incremented field ? ![]() PS : excuse my english french ![]() RE: Increment a field in the query builder - Rufnex - 11-30-2014 Write this PHP Code: $this->db->set('f_right', 'f_right+1', false); RE: Increment a field in the query builder - SquallX - 11-30-2014 Oh my bad. I note. Thanks |