Doing UPDATE with Doctrine and a String as Parameter
Today I had to extend a few Doctrine queries and one of these modifications consisted of changing the parameter of an UPDATE query from integer to string – and whoops! It didn’t work anymore…
When using $query->getSql(); I noticed that it wanted to do something like this:
UPDATE data SET date = 2009-12-14 WHERE ...
and of course mySQL doesn’t like passing date strings without proper quotes…
The query looked like this:
$query->UPDATE('Data')->set('date', $myNewDate)->where(...)
which I had to subsitute with
$query->UPDATE('Data')->set('date', '?', $myNewDate)->where(...)
Note the '?' in the middle – now it works
