• <bdo id='LNlHo'></bdo><ul id='LNlHo'></ul>
  • <small id='LNlHo'></small><noframes id='LNlHo'>

      <i id='LNlHo'><tr id='LNlHo'><dt id='LNlHo'><q id='LNlHo'><span id='LNlHo'><b id='LNlHo'><form id='LNlHo'><ins id='LNlHo'></ins><ul id='LNlHo'></ul><sub id='LNlHo'></sub></form><legend id='LNlHo'></legend><bdo id='LNlHo'><pre id='LNlHo'><center id='LNlHo'></center></pre></bdo></b><th id='LNlHo'></th></span></q></dt></tr></i><div id='LNlHo'><tfoot id='LNlHo'></tfoot><dl id='LNlHo'><fieldset id='LNlHo'></fieldset></dl></div>
    1. <tfoot id='LNlHo'></tfoot>
      <legend id='LNlHo'><style id='LNlHo'><dir id='LNlHo'><q id='LNlHo'></q></dir></style></legend>

      1. Symfony 2:使用理论查询构建器在非相关表上进行 INNER JOIN

        Symfony 2: INNER JOIN on non related table with doctrine query builder(Symfony 2:使用理论查询构建器在非相关表上进行 INNER JOIN)

          • <bdo id='M5NQX'></bdo><ul id='M5NQX'></ul>
              <tbody id='M5NQX'></tbody>
            • <tfoot id='M5NQX'></tfoot>
              <i id='M5NQX'><tr id='M5NQX'><dt id='M5NQX'><q id='M5NQX'><span id='M5NQX'><b id='M5NQX'><form id='M5NQX'><ins id='M5NQX'></ins><ul id='M5NQX'></ul><sub id='M5NQX'></sub></form><legend id='M5NQX'></legend><bdo id='M5NQX'><pre id='M5NQX'><center id='M5NQX'></center></pre></bdo></b><th id='M5NQX'></th></span></q></dt></tr></i><div id='M5NQX'><tfoot id='M5NQX'></tfoot><dl id='M5NQX'><fieldset id='M5NQX'></fieldset></dl></div>

                1. <legend id='M5NQX'><style id='M5NQX'><dir id='M5NQX'><q id='M5NQX'></q></dir></style></legend>
                2. <small id='M5NQX'></small><noframes id='M5NQX'>

                  本文介绍了Symfony 2:使用理论查询构建器在非相关表上进行 INNER JOIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用原则查询构建器构建一个查询,该查询构建器连接一个不相关的表,如下所示:

                  I'm trying to build a query with the doctrine query builder which joins a non related table like this:

                  $query = $this->createQueryBuilder('gpr')
                          ->select('gpr, p')
                          ->innerJoin('TPost', 'p')
                          ->where('gpr.contentId = p.contentId')
                  

                  但这不起作用.我仍然收到错误:

                  But this doesn't work. I still get an error:

                  错误:连接路径表达式中使用了标识变量 TPost,但之前未定义.

                  Error: Identification Variable TPost used in join path expression but was not defined before.

                  我搜索了此错误消息,每个人都回答使用表别名 + 属性,如 p.someAttribute.但我要加入的表与我开始选择的表无关.

                  I searched for this error message and everybody answered to use the table alias + attribute like p.someAttribute. But the table I want to join isn't related in the table I start my select from.

                  作为一个普通的mysql查询,我会这样写:

                  As a normal mysql query i would write it like this:

                  SELECT * FROM t_group_publication_rel gpr 
                  INNER JOIN t_post p 
                  WHERE gpr.content_id = p.content_id
                  

                  任何想法我做错了什么?

                  Any ideas what i'm doing wrong?

                  推荐答案

                  今天我正在处理类似的任务,并记得我打开了这个问题.我不知道它是从哪个学说版本开始工作的,但现在您可以轻松地将子类加入继承映射中.所以像这样的查询没有任何问题:

                  Today I was working on similar task and remembered that I opened this issue. I don't know since which doctrine version it's working but right now you can easily join the child classes in inheritance mapping. So a query like this is working without any problem:

                  $query = $this->createQueryBuilder('c')
                          ->select('c')
                          ->leftJoin('MyBundleName:ChildOne', 'co', 'WITH', 'co.id = c.id')
                          ->leftJoin('MyBundleName:ChildTwo', 'ct', 'WITH', 'ct.id = c.id')
                          ->orderBy('c.createdAt', 'DESC')
                          ->where('co.group = :group OR ct.group = :group')
                          ->setParameter('group', $group)
                          ->setMaxResults(20);
                  

                  我在使用继承映射的父类中启动查询.在我之前的帖子中,如果我没记错的话,这是一个不同的起点,但同样的问题.

                  I start the query in my parent class which is using inheritance mapping. In my previous post it was a different starting point but the same issue if I remember right.

                  因为当我开始这个问题时这是一个大问题,所以我认为对于其他不了解它的人来说也可能很有趣.

                  Because it was a big problem when I started this issue I think it could be also interesting for other people which don't know about it.

                  这篇关于Symfony 2:使用理论查询构建器在非相关表上进行 INNER JOIN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  When should use doctrine ORM and when zend-db-table?(什么时候应该使用学说 ORM,什么时候应该使用 zend-db-table?)
                  Doctrine - self-referencing entity - disable fetching of children(Doctrine - 自引用实体 - 禁用获取子项)
                  Doctrine 2, query inside entities(原则 2,实体内部查询)
                  Complex WHERE clauses using the PHP Doctrine ORM(使用 PHP Doctrine ORM 的复杂 WHERE 子句)
                  Doctrine - OneToMany relation, all result row doesn#39;t fetch in object(Doctrine - OneToMany 关系,所有结果行不获取对象)
                  Doctrine and unrefreshed relationships(教义和未更新的关系)
                  • <bdo id='w4hkd'></bdo><ul id='w4hkd'></ul>
                        <tbody id='w4hkd'></tbody>

                        <small id='w4hkd'></small><noframes id='w4hkd'>

                          <legend id='w4hkd'><style id='w4hkd'><dir id='w4hkd'><q id='w4hkd'></q></dir></style></legend>
                          <tfoot id='w4hkd'></tfoot>

                            <i id='w4hkd'><tr id='w4hkd'><dt id='w4hkd'><q id='w4hkd'><span id='w4hkd'><b id='w4hkd'><form id='w4hkd'><ins id='w4hkd'></ins><ul id='w4hkd'></ul><sub id='w4hkd'></sub></form><legend id='w4hkd'></legend><bdo id='w4hkd'><pre id='w4hkd'><center id='w4hkd'></center></pre></bdo></b><th id='w4hkd'></th></span></q></dt></tr></i><div id='w4hkd'><tfoot id='w4hkd'></tfoot><dl id='w4hkd'><fieldset id='w4hkd'></fieldset></dl></div>