不相关实体之间的DQL加入? [英] DQL join between unrelated entities?
问题描述
可以使用WITH DQL运算符在不相关实体之间建立DQL连接吗?或是绝对强制性的关系?
我与Category和CategorySubsription有单向关系。哪个类别订阅与类别有多对一的单向关系。我想要获取一个类别c的列表,然后添加类别订阅cs WITH cs.category_id = c.id AND cs.user_id = value。
我可以这样做吗?
从Doctrine版本2.3开始,如 blog 。
在文档如果你知道在哪里看向下滚动到15.2.4。DQL SELECT示例下的最后一个例子:
无关联的实体之间的连接是不可能的,直到版本2.4,您可以使用以下语法生成任意连接:
<?php
$ query = $ em-> createQuery('SELECT u FROM User u JOIN Blacklist b WITH u.email = b.email');
我知道它说直到版本2.4都不可能,但是它的起始于2.3! / p>
Can I have a DQL join between unrelated entities using WITH DQL operator? OR is definign relationship absolutely mandatory?
I have a unidirectional relationship with Category and CategorySubsription. Where CategorySubscription has a many to one unidirectional relationship with Category. I want to grab a list of Categories c and left join CategorySubscription cs WITH cs.category_id = c.id AND cs.user_id = value.
Can I do this somehow?
Starting with Doctrine version 2.3 you can, as mentioned in a blog.
It's also mentioned in the docs if you know where to look. Scroll down to the last example under "15.2.4. DQL SELECT Examples":
Joins between entities without associations were not possible until version 2.4, where you can generate an arbitrary join with the following syntax:
<?php
$query = $em->createQuery('SELECT u FROM User u JOIN Blacklist b WITH u.email = b.email');
I know it says "not possible until version 2.4", but it definitely works starting with 2.3!
这篇关于不相关实体之间的DQL加入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!