CodeIgniter Forums
Problem with escaping in query. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Problem with escaping in query. (/showthread.php?tid=2030)



Problem with escaping in query. - El Forum - 07-12-2007

[eluser]Unknown[/eluser]
Hi, sorry for my english.

I have a problem with escaping in mysql queries. It looks so:

Code:
...
$data['age'] = 'age + 1';
echo $this->db->update_string('table', $data, $where)

This code returns "... age = 'age + 1'" and it does not have an effect.

Unfortunately i have to use this database class, because i use loops and i have different count of variables to update in query.

Thanks for answer.


Problem with escaping in query. - El Forum - 07-18-2007

[eluser]marcoss[/eluser]
That won`t work because the 'age' is not linked to the actual database table, you should build a custom update query and use $this->db->query() to accomplish that, or get the 'age' value first and send it already incremented to the AR call.