<tfoot id='9jciH'></tfoot>

<legend id='9jciH'><style id='9jciH'><dir id='9jciH'><q id='9jciH'></q></dir></style></legend>

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

      <small id='9jciH'></small><noframes id='9jciH'>

      1. 无效的参数号:绑定变量的数量与 Doctrine 中的标记数量不匹配

        Invalid parameter number: number of bound variables does not match number of tokens in Doctrine(无效的参数号:绑定变量的数量与 Doctrine 中的标记数量不匹配)

            <tbody id='3NGGq'></tbody>

          <legend id='3NGGq'><style id='3NGGq'><dir id='3NGGq'><q id='3NGGq'></q></dir></style></legend>

            <tfoot id='3NGGq'></tfoot>
          1. <small id='3NGGq'></small><noframes id='3NGGq'>

                <bdo id='3NGGq'></bdo><ul id='3NGGq'></ul>

                  <i id='3NGGq'><tr id='3NGGq'><dt id='3NGGq'><q id='3NGGq'><span id='3NGGq'><b id='3NGGq'><form id='3NGGq'><ins id='3NGGq'></ins><ul id='3NGGq'></ul><sub id='3NGGq'></sub></form><legend id='3NGGq'></legend><bdo id='3NGGq'><pre id='3NGGq'><center id='3NGGq'></center></pre></bdo></b><th id='3NGGq'></th></span></q></dt></tr></i><div id='3NGGq'><tfoot id='3NGGq'></tfoot><dl id='3NGGq'><fieldset id='3NGGq'></fieldset></dl></div>
                  本文介绍了无效的参数号:绑定变量的数量与 Doctrine 中的标记数量不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  使用 Doctrine 2 我想获取一些用户是另一个用户的联系人.user 表包含这些用户之间的映射.函数中的查询会返回如下错误:

                  Using Doctrine 2 I want to get some users that are contacts of another user. The table user contains the mapping between those users. The query in the function will return the following error:

                  参数号无效:绑定变量的数量与标记的数量不匹配.

                  Invalid parameter number: number of bound variables does not match number of tokens.

                  但据我所知,$str 设置为b",$ownerId 设置为2",两者均由 setParameters函数.

                  However to my best understanding $stris set to "b" and $ownerId is set to "2" and both are assigned by the setParameters function.

                   protected function getContactBySubstring($str, $ownerId) {
                          echo $str;
                          echo $ownerId;
                          $em = $this->getDoctrine()->getEntityManager();
                          $qb = $em->createQueryBuilder();
                          $qb->add('select', 'u')
                                  ->add('from', 'PastonVerBundleEntityUser u, PastonVerBundleEntityContact c')
                                  ->add('where', "c.owner = ?1 AND c.contact = u.id AND u.username LIKE '?2'")
                                  ->add('orderBy', 'u.firstname ASC, u.lastname ASC')
                                  ->setParameters(array (1=> $ownerId, 2=> '%'.$str.'%'));
                  
                          echo $qb->getDql();
                          $query = $qb->getQuery();
                          $users = $query->getResult();
                          foreach($users as $user)
                              echo $user->getUsername();
                          exit;
                          //return $contacts;
                      }
                  

                  推荐答案

                  不要用引号将查询文本中的任何参数括起来!

                  Don't surround any of the parameters in your query text with quotes!

                  ->add('where', "c.owner = ?1 AND c.contact = u.id AND u.username LIKE '?2'")
                  

                  应该是

                  ->add('where', "c.owner = ?1 AND c.contact = u.id AND u.username LIKE ?2")
                  

                  这篇关于无效的参数号:绑定变量的数量与 Doctrine 中的标记数量不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

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

                        1. <legend id='MbK72'><style id='MbK72'><dir id='MbK72'><q id='MbK72'></q></dir></style></legend>
                            <tfoot id='MbK72'></tfoot>

                          1. <small id='MbK72'></small><noframes id='MbK72'>

                              <tbody id='MbK72'></tbody>