gpt4 book ai didi

php - 在 Doctrine 中使用 IS TRUE sql 语句

转载 作者:行者123 更新时间:2023-11-29 11:02:57 24 4
gpt4 key购买 nike

假设我有一个 SQL 查询:

SELECT phone_id, name
FROM calls c WHERE (c.user_id = 2241
AND c.phone_id IN ("Google Pixel","Samsung")

AND (c.name IN ("Alex","John")) OR c.name IS NULL) IS TRUE)

效果很好:IS TRUE 语句将 (c.name IN ("Alex","John")) OR c.name IS NULL) 表达式计算为单个的。

但问题是 Doctrine 不支持 IS TRUE 语句,这样的查询会导致错误。

How can I achieve the same functionality using Doctrine, but obviously avoiding IS TRUE statement?

最佳答案

评论太长了。

is true 的目的是什么?

为什么不直接将查询写成这样呢?

SELECT phone_id, name
FROM calls c
WHERE c.user_id = 2241 AND
c.phone_id IN ('Google Pixel', 'Samsung') AND
(c.name IN ('Alex', 'John') OR c.name IS NULL)

关于php - 在 Doctrine 中使用 IS TRUE sql 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41911514/

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