php - Doctrine 查询构建器中的嵌套查询

标签 php mysql symfony doctrine-orm doctrine

如何使用 Doctrine Query Builder 构建嵌套查询?

我的 mysql 查询如下所示:

SELECT subquery1.*
FROM 
 (SELECT * FROM product 
  WHERE for_her = true && age_teenagers = true && special = true) subquery1
WHERE subquery1.song_rock =true || subquery1.describe_beauty = true;

如何在 Product Entity Repository 中将其转换为 Doctrine 查询?

最佳答案

在这种情况下,查询可能很容易重新格式化为通常的非嵌套查询。 据我所知

SELECT * FROM product 
  WHERE for_her = true AND age_teenagers = true AND special = true
and (song_rock =true OR describe_beauty = true)

因此

Select P from Product P
Where P.forHer=true AND P.ageTeenages=true AND P.specials=true and (P.songRock=true OR P.describeBeauty=true)

关于php - Doctrine 查询构建器中的嵌套查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40240876/

相关文章:

使用 mysql 结果构造 C# 操作

mysql - 两列之间无法正常工作

symfony - Silex - 从测试中分派(dispatch)时不执行监听器

Symfony 子实体仅被验证为类型,跳过它自己的验证

php - Symfony2 - SonataAdmin - 空 admin_list block

php - 无法使用 user_id 以编程方式登录

php - 我什么时候必须关闭 mysqli(数据库)连接?

PHPunit 没有在 Travis CI 上执行测试

php - 单击按钮时将数据从 MySQL 数据库加载到 HTML 文本框

mysql - 如何按照我的意愿将文本文件最好地上传到数据库中? (在C中)