大佬教程收集整理的这篇文章主要介绍了php – Doctrine QueryBuilder和concat问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
class PlayerRepository extends EntityRepository { public function findByPartialNameMatch($Trainer,$fullName) { $qb = $this->createQueryBuilder('tp'); $qb->innerJoin('tp.player','p') ->where($qb->expr()->andX( $qb->expr()->orX( $qb->expr()->like( $qb->expr()->concat('p.firstName',$qb->expr()->concat(' ','p.lastName')),$qb->expr()->literal($fullName.'%') ),$qb->expr()->like( $qb->expr()->concat('p.lastName','p.firstName')),$qb->expr()->literal($fullName.'%') ) ),$qb->expr()->eq('tp.Trainer','?1') ) ) ->groupBy('p.id') ->orderBy('p.lastName','ASC') ->orderBy('p.firstName','ASC') ->setParameter(1,$Trainer); return $qb->getQuery()->getResult(); }
}
[Syntax Error] line 0,col 123: Error: Expected StateFieldPathExpression | String | InputParameter | FunctionsReturningStrings | AggregateExpression,got ','
查看堆栈跟踪,显示以下内容:
at QueryException ::syntaxError ('line 0,col 123: Error: Expected StateFieldPathExpression | String | InputParameter | FunctionsReturningStrings | AggregateExpression,'') in D:\Work\vendor\doctrine\lib\Doctrine\ORM\Query\Parser.php at line 396 -+ at Parser ->syntaxError ('StateFieldPathExpression | String | InputParameter | FunctionsReturningStrings | AggregateExpression') in D:\Work\vendor\doctrine\lib\Doctrine\ORM\Query\Parser.php at line 2391 -+ at Parser ->StringPriMary () in D:\Work\vendor\doctrine\lib\Doctrine\ORM\Query\AST\Functions\ConcatFunction.php at line 60 -+ at ConcatFunction ->parse (object(Parser)) in D:\Work\vendor\doctrine\lib\Doctrine\ORM\Query\Parser.php at line 2852 -
从上面可以看出,这个问题与concat Helper函数有某种关系,并且该函数需要枚举输入,但不知何故(?)收到了一个逗号(,).
上面的代码有什么问题?搜索时间无法解决问题.
谢谢你的帮助!
$qb->expr()->concat(' ','p.lastName')
你不能只是放空间,因为教义期望这里有一些识别者.试试这个:
$qb->expr()->concat($qb->expr()->literal(' '),'p.lastName')
以上是大佬教程为你收集整理的php – Doctrine QueryBuilder和concat问题全部内容,希望文章能够帮你解决php – Doctrine QueryBuilder和concat问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。