作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
阅读 Doctrine 2 文档时 at this page我可以看到他们有两种方法来指定内部连接的条件:
// Example - $qb->expr()->innerJoin('u.Group', 'g', Expr\Join::WITH, 'g.manager_level = 100');
// Example - $qb->expr()->innerJoin('u.Group', 'g', 'WITH', $qb->expr()->eq('g.manager_level', '100'));
public function innerJoin($join, $alias, $conditionType = null, $condition = null); // Returns Expr\Join instance
和
// Example - $qb->innerJoin('u.Group', 'g', Expr\Join::ON, $qb->expr()->and($qb->expr()->eq('u.group_id', 'g.id'), 'g.name = ?1'))
// Example - $qb->innerJoin('u.Group', 'g', 'ON', 'u.group_id = g.id AND g.name = ?1')
public function innerJoin($join, $alias = null, $conditionType = null, $condition = null);
我不明白其中的区别,因为 innerjoin 仅在找到匹配项时才返回内容,而且我找不到任何关于此的文档。
谢谢
最佳答案
看起来它们是同义词。基于 Doctrine EBNF 表达式(在 http://docs.doctrine-project.org/en/2.0.x/reference/dql-doctrine-query-language.html#from-join-and-index-by 找到),Doctrine 似乎更喜欢 WITH
。然而,MySQL(可能还有其他 SQL 数据库)使用 ON
,所以我猜测 Doctrine 的作者包含了该表达式以避免混淆他们的用户。
Doctrine 的开发者已经编写了他们自己的 SQL 变体——这是因为 Doctrine 是一个对象关系管理器(ORM),而不是一个直接的查询构建器。他们的 SQL 变体旨在与他们的对象一起工作。所以,例如,如果你正在构建 user
和 group
模型并想表达它们之间的关系,你可以用 Doctrine 的查询语言来做,它会处理JOIN
条件自动发生。
关于php - Inner Join WITH 和 inner join ON 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23023660/
我是一名优秀的程序员,十分优秀!