![]() |
update query - 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: update query (/showthread.php?tid=35876) |
update query - El Forum - 11-14-2010 [eluser]André Padez[/eluser] Hi, I wish to make something like: Code: $query = 'update table set field = value where id = 3'; Quote:$query = 'select * from table where id = 3'; does anyone know how i can use the first form? Thanx update query - El Forum - 11-14-2010 [eluser]Rolly1971[/eluser] i assume 'id' is the primary key? if so it should only affect 1 row if successful Code: function update_table($id, $value) update query - El Forum - 11-14-2010 [eluser]Georgi Veznev[/eluser] [quote author="André Padez" date="1289775347"]Hi, I wish to make something like: Code: $query = 'update table set field = value where id = 3'; Quote:$query = 'select * from table where id = 3'; does anyone know how i can use the first form? Thanx[/quote] http://ellislab.com/codeigniter/user-guide/database/helpers.html Code: $query = 'update table set field = value where id = 3'; update query - El Forum - 11-14-2010 [eluser]André Padez[/eluser] Thank you both. @Rolly1971, when you say it returns true if successful, i don't think it's what i'm looking for; i presume it will return true even if it affects zero rows, right? @Georgi Veznev, i believe that is exactly what i was looking for. that's what i am going to use update query - El Forum - 11-14-2010 [eluser]André Padez[/eluser] Oh, and @Georgi Veznev it's not Code: $count = $result->affected_rows(); Code: $count = $this->db->affected_rows(); |