CodeIgniter Forums
difference between update and set - 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: difference between update and set (/showthread.php?tid=23282)



difference between update and set - El Forum - 10-06-2009

[eluser]ranjitbd[/eluser]
//what is the difference between SET and UPDATE method in active records with CI


difference between update and set - El Forum - 10-06-2009

[eluser]davidbehler[/eluser]
With
Code:
$this->db->set('field_name', 'value');
you tell the database class what value should be set for what field, but no change is made to the database
Code:
$this->db->update('table_name');
finally tells the database class to update the tables and set the before defined values.

You can use this with
Code:
$this->db->insert('table_name');
as well. First set the values for all fields you want to fill, then call the insert method and have the database class insert a new row.