条件IF语句在PHP Doctrine 1.2 SET语句中 [英] Conditional IF statement in a PHP Doctrine 1.2 SET statement
本文介绍了条件IF语句在PHP Doctrine 1.2 SET语句中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想找到SET行的正确语法:
I would like find the correct syntax for the SET line:
Doctrine_Query::create()
->update('Media m')
->set('m.fallback IF(m.id = ?, 1, 0)', $id) <-- not correct
->execute();
感谢任何帮助!
推荐答案
我认为可以用两个查询:
I think that could be done with two queries:
Doctrine_Query::create()
->update('Media m')
->set('m.fallback', 1)
->where('m.id = ?', $id)
->execute();
Doctrine_Query::create()
->update('Media m')
->set('m.fallback', 0)
->where('m.id != ?', $id)
->execute();
我不知道它是否适合你,但至少会做你想要的。可能不开箱即用 ,因为我手边没有Doctrine 1.2,所以不能测试。但我认为这个想法很清楚:)
I don't know if it suits you, but at least that will do what you want. May not work out of the box, as I don't have Doctrine 1.2 at hand, so can't test this. But I think the idea is clear :)
这篇关于条件IF语句在PHP Doctrine 1.2 SET语句中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文