0

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?

Frank N
  • 9,625
  • 4
  • 80
  • 110
  • Apparently, here is an answer. But I habe yet to understand, how Doctrine knows, if e.g. "John" is a column or a literal...: http://stackoverflow.com/questions/4803436/update-multiple-columns-with-doctrine-in-symfony – Frank N Nov 25 '11 at 11:47

2 Answers2

3

Use:

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

This is the equivalent of doing the following in DQL

SET name = ?
dbellizzi
  • 713
  • 8
  • 18
0

You can also use :

$q = Doctrine_Query::create()
    ->update('mytable')
    ->set('name', ':name')
    ->setParameter('name', 'foo bar')
Yoann Kergall
  • 2,993
  • 5
  • 22
  • 23