1. <tfoot id='UNCKR'></tfoot>
    2. <small id='UNCKR'></small><noframes id='UNCKR'>

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

        使用查询构建器删除 Doctrine 2

        Doctrine 2 delete with query builder(使用查询构建器删除 Doctrine 2)
      2. <i id='2Rv6v'><tr id='2Rv6v'><dt id='2Rv6v'><q id='2Rv6v'><span id='2Rv6v'><b id='2Rv6v'><form id='2Rv6v'><ins id='2Rv6v'></ins><ul id='2Rv6v'></ul><sub id='2Rv6v'></sub></form><legend id='2Rv6v'></legend><bdo id='2Rv6v'><pre id='2Rv6v'><center id='2Rv6v'></center></pre></bdo></b><th id='2Rv6v'></th></span></q></dt></tr></i><div id='2Rv6v'><tfoot id='2Rv6v'></tfoot><dl id='2Rv6v'><fieldset id='2Rv6v'></fieldset></dl></div>
        <legend id='2Rv6v'><style id='2Rv6v'><dir id='2Rv6v'><q id='2Rv6v'></q></dir></style></legend>
      3. <tfoot id='2Rv6v'></tfoot>

        <small id='2Rv6v'></small><noframes id='2Rv6v'>

              • <bdo id='2Rv6v'></bdo><ul id='2Rv6v'></ul>

                    <tbody id='2Rv6v'></tbody>
                • 本文介绍了使用查询构建器删除 Doctrine 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有两个具有 OneToMany 关系的实体,ProjectServices.现在我想通过 project_id 删除所有服务.

                  I have two Entities with relation OneToMany, Project and Services. Now i want to remove all the services by project_id.

                  第一次尝试:

                  $qb = $em->createQueryBuilder();
                  $qb->delete('Services','s');
                  $qb->andWhere($qb->expr()->eq('s.project_id', ':id'));
                  $qb->setParameter(':id',$project->getId());
                  

                  此尝试失败,出现异常 Entity Service does not have property project_id.确实,该属性不存在,它只是在数据库表中作为外键.

                  This attempt fails with the Exception Entity Service does not have property project_id. And it's true, that property does not exists, it's only in database table as foreign key.

                  第二次尝试:

                  $qb = $em->createQueryBuilder();
                  $qb->delete('Services','s')->innerJoin('s.project','p');
                  $qb->andWhere($qb->expr()->eq('p.id', ':id'));
                  $qb->setParameter(':id',$project->getId());
                  

                  这个也会生成一个无效的 DQL 查询.

                  This one generetate a non valid DQL query too.

                  欢迎提供任何想法和示例.

                  Any ideas and examples will be welcome.

                  推荐答案

                  您使用的是 DQL,而不是 SQL,所以不要在您的条件中引用 ID,而是引用对象.

                  You're working with DQL, not SQL, so don't reference the IDs in your condition, reference the object instead.

                  因此您的第一个示例将更改为:

                  So your first example would be altered to:

                  $qb = $em->createQueryBuilder();
                  $qb->delete('Services', 's');
                  $qb->where('s.project = :project');
                  $qb->setParameter('project', $project);
                  

                  这篇关于使用查询构建器删除 Doctrine 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='t5uci'><style id='t5uci'><dir id='t5uci'><q id='t5uci'></q></dir></style></legend>

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

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

                            <tfoot id='t5uci'></tfoot>