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

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

        <bdo id='szkXQ'></bdo><ul id='szkXQ'></ul>
      <legend id='szkXQ'><style id='szkXQ'><dir id='szkXQ'><q id='szkXQ'></q></dir></style></legend>

      1. Doctrine 2 DQL - 选择多对多字段为空的行?

        Doctrine 2 DQL - Select rows where a many-to-many field is empty?(Doctrine 2 DQL - 选择多对多字段为空的行?)
        <i id='8Xt1p'><tr id='8Xt1p'><dt id='8Xt1p'><q id='8Xt1p'><span id='8Xt1p'><b id='8Xt1p'><form id='8Xt1p'><ins id='8Xt1p'></ins><ul id='8Xt1p'></ul><sub id='8Xt1p'></sub></form><legend id='8Xt1p'></legend><bdo id='8Xt1p'><pre id='8Xt1p'><center id='8Xt1p'></center></pre></bdo></b><th id='8Xt1p'></th></span></q></dt></tr></i><div id='8Xt1p'><tfoot id='8Xt1p'></tfoot><dl id='8Xt1p'><fieldset id='8Xt1p'></fieldset></dl></div>

      2. <tfoot id='8Xt1p'></tfoot>

          <tbody id='8Xt1p'></tbody>
        <legend id='8Xt1p'><style id='8Xt1p'><dir id='8Xt1p'><q id='8Xt1p'></q></dir></style></legend>

        • <small id='8Xt1p'></small><noframes id='8Xt1p'>

                  <bdo id='8Xt1p'></bdo><ul id='8Xt1p'></ul>
                  本文介绍了Doctrine 2 DQL - 选择多对多字段为空的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在这个例子中我有两个类 - DeliveryMethod 和 Country.它们之间是多对多的关系.

                  I have two classes in this example - DeliveryMethod and Country. They have a many-to-many relationship with each other.

                  我想要做的是选择没有任何国家映射到它们的所有 DeliveryMethods.

                  What I want to do is select all DeliveryMethods that do not have any Countries mapped to them.

                  我可以做相反的事情,即选择至少有一个国家的所有交付方式 -

                  I can do the opposite, that is select all delivery methods that have at least one country -

                  SELECT m FROM DeliveryMethod m JOIN m.countries
                  

                  但我不知道如何选择国家字段为空的位置.在普通 SQL 中,我会执行以下操作(deliverymethod_country 是链接表):

                  But I can't figure out how to do select where the countries field is empty. In plain SQL I would do the following (deliverymethod_country is the linking table):

                  SELECT m.* FROM deliverymethods m
                  LEFT JOIN deliverymethod_country dc ON dc.deliverymethod_id = m.id
                  WHERE dc.deliverymethod_id IS NULL
                  

                  但是任何与此等效的 DQL 都不起作用,例如:

                  However any DQL equivalent of this doesn't work, for example:

                  SELECT m FROM DeliveryMethod m LEFT JOIN m.countries WHERE m.countries IS NULL
                  

                  这给了我这个错误:

                  [Syntax Error] line 0, col 75: Error: Expected end of string, got 'm'
                  

                  推荐答案

                  这个呢?假设 $qb 是您的查询构建器实例

                  What about this? Assuming $qb is your query builder instance

                  $qb->select('m')
                     ->from('DeliveryMethods','m')
                     ->leftJoin('m.countries','c')
                     ->having('COUNT(c.id) = 0')
                     ->groupBy('m.id');
                  

                  这将为您提供与国家/地区关联的 DeliveryMethods,关联国家/地区的数量为 0

                  This would give you the DeliveryMethods which is associated with countries and count of the associated countries is 0

                  这篇关于Doctrine 2 DQL - 选择多对多字段为空的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)
                  <legend id='LmWUo'><style id='LmWUo'><dir id='LmWUo'><q id='LmWUo'></q></dir></style></legend>
                  • <bdo id='LmWUo'></bdo><ul id='LmWUo'></ul>
                      <tbody id='LmWUo'></tbody>
                  • <i id='LmWUo'><tr id='LmWUo'><dt id='LmWUo'><q id='LmWUo'><span id='LmWUo'><b id='LmWUo'><form id='LmWUo'><ins id='LmWUo'></ins><ul id='LmWUo'></ul><sub id='LmWUo'></sub></form><legend id='LmWUo'></legend><bdo id='LmWUo'><pre id='LmWUo'><center id='LmWUo'></center></pre></bdo></b><th id='LmWUo'></th></span></q></dt></tr></i><div id='LmWUo'><tfoot id='LmWUo'></tfoot><dl id='LmWUo'><fieldset id='LmWUo'></fieldset></dl></div>

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

                        <tfoot id='LmWUo'></tfoot>