且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

“无映射字段”在Doctrine2中使用部分查询和复合键时

更新时间:2023-02-25 20:23:28

每当执行部分选择时需要包含您要选择的课程的主键。

Whenever performing a partial selection you need to include the primary key of the class you're selecting from.

您没有实际详细说明您的联系实体,但我假设主键字段该类是id。如果是这种情况,那么以下查询将会实现你以后的内容:

You haven't actually detailed your "Contact" entity but i'm assuming the primary key field of that class is "id". If this was the case then the following query will acheive what you're after:

SELECT c, PARTIAL t.{id, tag} FROM Contact c LEFT JOIN c.tags

这似乎没有记录:(

http://docs.doctrine-project.org/en/latest/reference/dql-doctrine-query-language.html#partial-object-syntax