Posted on 14th December 2009No Responses
Doing UPDATE with Doctrine and a String as Parameter

Today I had to extend a few queries and one of these modifications consisted of changing the parameter of an query from integer to – and whoops! It didn’t work anymore…

When using $query->(); I noticed that it wanted to do something like this:

data SET date = 2009-12-14 WHERE ...

and of course mySQL doesn’t like passing date strings without proper

The query looked like this:

$query->('Data')->set('date', $myNewDate)->where(...)

which I had to subsitute with

$query->('Data')->set('date', '?', $myNewDate)->where(...)

Note the '?' in the middle – now it works ;)

Share this on:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • MisterWong
  • MySpace
  • Reddit
  • RSS
  • Yahoo! Bookmarks

Related posts

Comments
Leave a Response
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <img src="">