Search code examples
doctrinedoctrine-1.2string-literalsdoctrine-query

How to set literal string values in Doctrine Update queries?


For doctrine 1.2, I find plenty of examples like these:

$q = Doctrine_Query::create()
->update('mytable')
->set('amount', 'amount+200')
->whereIn ('id', $ids);

What I want to do however is a different set:

->set('name', 'foo bar')

This however, leads to exception. Of course, because foo is no column, like amount. No luck with '´foo bar´' either. How can I clarify foo bar is a string literal?

I believe this is the right place to look, but I don't find further info. Also: I would love to know more about the 'mixed params' and 'string update' mentioned there. Perhaps there's a DOCTRINE::FLAG_LITERAL or such?


Solution

  • Use:

    ->set('name', '?', 'foo bar')
    

    This is the equivalent of doing the following in DQL

    SET name = ?