![]() |
Active Record; adding to an existing value? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Active Record; adding to an existing value? (/showthread.php?tid=5580) |
Active Record; adding to an existing value? - El Forum - 01-27-2008 [eluser]_asdf[/eluser] Using the activerecord class, I'm trying to update an existing value (think post count, etc) by N. In theory, it'd go like: Code: $this->db->set('columnName', 'columnName + 1'); But of course, the AR itself escapes it, so you end up with a query like Code: UPDATE TableName SET columnName = 'columnName + 1' WHERE columnId = '1' Then I figured maybe I could do it the way one does where comparisons, like so: Code: $this->db->set('columnName = columnName + ', 1); Code: UPDATE TableName SET columnName = columnName + = 1 WHERE columnId = '1' Is there a way to get this to produce the correct query, eg: Code: UPDATE TableName SET columnName = columnName + 1 WHERE columnId = '1' Any help & Suggestions most appreciated. (Its been ages since I used CI, but its so nice to be back. Aside from this one sticking issue.) Active Record; adding to an existing value? - El Forum - 01-27-2008 [eluser]xwero[/eluser] version 1.6 (SVN) solves this issue with an extra parameter Code: $this->db->set('columnName', 'columnName + 1',false); |