gpt4 book ai didi

doctrine - PHP Doctrine 1.2 SET 语句中的条件 IF 语句

转载 作者:行者123 更新时间:2023-12-04 22:01:34 26 4
gpt4 key购买 nike

我想找到 SET 行的正确语法:

Doctrine_Query::create()
->update('Media m')
->set('m.fallback IF(m.id = ?, 1, 0)', $id) <-- not correct
->execute();

感谢您的帮助!

最佳答案

我认为这可以通过两个查询来完成:

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,所以无法对此进行测试。但我认为这个想法很明确:)

关于doctrine - PHP Doctrine 1.2 SET 语句中的条件 IF 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6780026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com