CodeIgniter Forums
$this->db->update('page', $data)->where -- Not working - 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: $this->db->update('page', $data)->where -- Not working (/showthread.php?tid=9201)



$this->db->update('page', $data)->where -- Not working - El Forum - 06-16-2008

[eluser]EEssam[/eluser]
Hello,

Why method chaining is not working for me when trying to update? Is it only available for select statements?

http://ellislab.com/codeigniter/user-guide/database/active_record.html#update

Please clarify.


$this->db->update('page', $data)->where -- Not working - El Forum - 06-16-2008

[eluser]mglinski[/eluser]
Your chaining in reverse.
Try this: $this->db->where('id, $id)->update(’page’, $data);

For Refrence: Any db command that inserts, updates or deletes data goes last in a chain, right before you retrieve the result of the query. This should be quite obvious but is often confused for the newbies.
-Matt


$this->db->update('page', $data)->where -- Not working - El Forum - 06-16-2008

[eluser]EEssam[/eluser]
Thanks, that worked.