相关疑难解决方法(0)

Doctrine QueryBuilder和concat问题

我有以下代码,它依赖于Doctrine的QueryBuilder API来生成DQL状态.

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', $qb->expr()->concat(' ', '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();
}
Run Code Online (Sandbox Code Playgroud)

}

当我运行它时,Symfony2抛出以下错误消息:

[Syntax Error] line 0, col 123: Error: Expected StateFieldPathExpression | string |      InputParameter | FunctionsReturningStrings | AggregateExpression, got ',' 
Run Code Online (Sandbox Code Playgroud)

查看堆栈跟踪,显示以下内容:

at QueryException ::syntaxError ('line 0, col 123: Error: Expected   StateFieldPathExpression …
Run Code Online (Sandbox Code Playgroud)

php symfony doctrine-orm

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

doctrine-orm ×1

php ×1

symfony ×1