• <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <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>