[MYSQL] Update data error - 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: [MYSQL] Update data error (/showthread.php?tid=17147) |
[MYSQL] Update data error - El Forum - 03-26-2009 [eluser]Clooner[/eluser] Code: $this->db->set('read' , 1); Code: UPDATE news SET read = 1 WHERE `id` = '9' I can change the code to Code: $this->db->set('`read`' , 1); Code: UPDATE news SET `read` = 1 WHERE `id` = '9' [MYSQL] Update data error - El Forum - 03-27-2009 [eluser]TheFuzzy0ne[/eluser] Please could you post the exact error MySQL gives you? [MYSQL] Update data error - El Forum - 03-27-2009 [eluser]Clooner[/eluser] [quote author="TheFuzzy0ne" date="1238170222"]Please could you post the exact error MySQL gives you?[/quote] It is a simple error to fix but I just find it strange. This is the report I get from CI Code: Error Number: 1064 [MYSQL] Update data error - El Forum - 03-27-2009 [eluser]TheFuzzy0ne[/eluser] What version of CodeIgniter are you using? The identifiers should be protected automatically. Have you changed anything, by either adding a custom library, or editing the core files? Here's what the $this->db->set() method looks like in 1.7.1: Code: /** [MYSQL] Update data error - El Forum - 03-27-2009 [eluser]Clooner[/eluser] I've found the fault. It is a mysql thing because the name of the column is "read" which is a reserved sql statement or word. But what is the reason for CI not escaping the column names? [MYSQL] Update data error - El Forum - 03-27-2009 [eluser]TheFuzzy0ne[/eluser] What version of CodeIgniter are you using? |