CodeIgniter Forums
how to - 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: how to (/showthread.php?tid=48770)



how to - El Forum - 01-27-2012

[eluser]rafi_ccj[/eluser]
how can i update my table values by incrementing with the previous value using active record? i mean newValue=previousValue+newValue...is it possible?

update table set area = area+20 where id=2;

How can I do this with active record?



how to - El Forum - 01-28-2012

[eluser]Aken[/eluser]
Use the set() function for that, and make sure to flag the third param as false so it does not auto-escape that part of the query. Adjust as needed.
Code:
$query = $this->db->set('column', 'column + 10', false)
->where('id', $id)
->update('table');



how to - El Forum - 01-28-2012

[eluser]rafi_ccj[/eluser]
thanks!!! is it possible for insert?