当我似乎在我的查询中使用参数时,我收到一个错误
Invalid parameter number: number of bound variables does not match number of tokens
这是我的代码
public function GetGeneralratingWithUserRights($user,$thread_array) { $parameters = array( 'thread' => $thread_array['thread'],'type' => '%'.$thread_array['type'].'%' ); $dql = 'SELECT p.type,AVG(p.value) FROM TrackerMembersBundle:rating p GROUP BY p.thread,p.type'; $query = $this->em->createquery($dql) ->setParameters($parameters); $ratings = $query->execute(); return $ratings; }
如何正确配置参数数组?
解决方法
您没有在查询中包含参数.
$parameters = array( 'thread' => $thread_array['thread'],'type' => '%'.$thread_array['type'].'%' ); $dql = 'SELECT p.type,AVG(p.value) FROM TrackerMembersBundle:rating p WHERE p.thread=:thread AND type LIKE :type GROUP BY p.thread,p.type'; $query = $this->em->createquery($dql) ->setParameters($parameters);
原文地址:https://www.jb51.cc/mssql/79971.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。