且构网

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

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

更新时间:2023-02-25 20:45:19

每当执行部分选择时,您都需要包含您从中选择的类的主键.

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