Doctrine Regular vs Fetch join(Doctrine Regular vs Fetch join)
问题描述
在原则上,regular 和 fetch join 之间的区别是什么?我不只是通过阅读 文档.
in doctrine, whats the diff between regular and fetch join? i dont get it just by reading the docs.
// regular
$query = $em->createQuery("SELECT u FROM User u JOIN u.address a WHERE a.city = 'Berlin'");
$users = $query->getResult();
// fetch
$query = $em->createQuery("SELECT u, a FROM User u JOIN u.address a WHERE a.city = 'Berlin'");
$users = $query->getResult();
fetch join 的目的是什么?如果我 select u, a
为什么我只是得到 users
($users = $query->getResult();
)?如果我使用常规连接,我可能可以使用 $user->getAddresses()
来访问相关对象?
whats the purpose of fetch join? if i select u, a
why am i just getting users
($users = $query->getResult();
)? if i use a regular join, i can probably use $user->getAddresses()
to access the related objects?
推荐答案
我认为文档描述得很好.如果您使用 fetch join,相关实体将包含在水合结果中.否则它们不会,如果您随后尝试访问它们,它将触发另一个查询以获取信息.
I think the docs describe it pretty well. If you use a fetch join, the related entities will be included in the hydrated result. Otherwise they won't, and if you then try to access them it'll fire off another query to get the information.
这只是是否应将其包含在结果中的问题.
It's simply a matter of whether or not it should be included in the results.
这篇关于Doctrine Regular vs Fetch join的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Doctrine Regular vs Fetch join


- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- Laravel 仓库 2022-01-01