Incrementing db 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: Incrementing db value (/showthread.php?tid=6682) |
Incrementing db value - El Forum - 03-07-2008 [eluser]unknownserv[/eluser] Is it possible to update a table and increment a value by 1 with active record? As the update data i'm using Code: <?php Any ideas? Cheers. Incrementing db value - El Forum - 03-07-2008 [eluser]sikkle[/eluser] The point is usually you use auto-incremente but i assume that you already know that. You better to go with "get the last id number" $field = $last_id_number + 1; good luck! Incrementing db value - El Forum - 03-07-2008 [eluser]Pygon[/eluser] Not really the point to assume that he's trying to add an "id", especially since he wants to UPDATE a record, and increment it by one, which means he's probably doing something like inserting a new item higher in a weighting row or something similar. unknownserv: set('field','field + 1',FALSE); //Might give this a try. Incrementing db value - El Forum - 03-07-2008 [eluser]unknownserv[/eluser] Its for a count of users currently on a page, so autoincrement wouldn't work for that. Thanks for the suggestion, I done a bit more searching and found that $this->db->set() has a 3rd parameter that can be set to false so that it doesn't escape strings. EDIT: Thanks for the above reply! |