Doctrine: Set field value to SQL expression
I need to set value in mapped record to some arbitrary sql expression, so on obj.save()
it would be used directly开发者_StackOverflow社区, w/out escaping/quoting.
Something like this:
obj.location = "Point($x, $y)";
obj.save();
Which should result in query like UPDATE ... SET location = Point(..., ...) WHERE ...;
However I cannot find anything like this in the docs, except DQL ->update()->set()
. I'd prefer to not use DQL, since it is used in both insert and update contexts.
Turns out its just
obj.location = new Doctrine_Expression("Point(10, 10)");
but not documented anywhere besides source code.
精彩评论