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


基础教程推荐
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01