Incremental SET with active query not working |
[eluser]Dandy_andy[/eluser]
Ok, so where am I going wrong here... I just want to increment a value by 1 but it doesn't seem to work. I've checked all field names and all is correct. I'm using two WHERE statements - is that where the problem is? Code: $this->db->set('read', 'read + 1'); I've checked the values of $section_id and $post_id and both are returning the correct numeric value. But the column READ isn't being updated in my DB... Any ideas? Thx.
[eluser]PhilTem[/eluser]
Third argument to set function call must be FALSE to avoid auto-escaping Code: $this->db->set('read', 'read + 1', FALSE); Source here
[eluser]Dandy_andy[/eluser]
Thanks, but when I did that, I got an SQL syntax error... "read + 1 WHERE `section_id` = `1` AND `ID` = `6` at line 1" UPDATE `forum_posts` SET `read` = read + 1 WHERE `section_id` = `1` AND `ID` = `6` However, I could see that the "read + 1" syntax wasn't escaped so by adding `` around the last read, it seems to have solved the issue.
[eluser]smilie[/eluser]
In you case, I would recommend: Code: $this->db->set('read = read + 1', '', FALSE); Cheers, Smilie
|
Welcome Guest, Not a member yet? Register Sign In |