语法错误第 0 行,第 70 栏:错误:预期 Doctrine\ORM\Query\Lexer::T_INSTANCE,得到“.”

问题描述 投票:0回答:1

我想发出请求,从我的表中检索包含名为“stat”的属性的元素。该属性是一个鉴别器。当我根据鉴别器检索元素时,如下文https://github.com/doctrine/orm/issues/4462所示,我遇到以下错误:

[Syntax Error] line 0, col 70: Error: Expected Doctrine\ORM\Query\Lexer::T_INSTANCE, got '.'

在第一部分中,您将找到鉴别器的注释,在第二部分中,您将找到我的存储库的方法。

/**
 * @ORM\DiscriminatorMap({
 *     "a" = "A",
 *     "b" = "B"
 * }) * 
**/
abstract class Stat implements JsonSerializable
{
    public function findWithFilter(array $params): array
    {
        $qb = $this->createQueryBuilder('ftch');
        if (isset($params['networkType']) && count($params['networkType']) > 1) {
            $orX = $qb->expr()->orX();
            foreach ($params['networkType'] as $networkType) {
                if ($networkType === NetworkType::A->value) {
                    $orX->add($qb->expr()->isInstanceOf('ftch.stat', 'App\Entity\A'));
                } elseif ($networkType === NetworkType::B->value) {
                    $orX->add($qb->expr()->isInstanceOf('ftch.stat', 'App\Entity\B'));
                }
            }

            $qb->andWhere($orX);
        }
        return $qb->getQuery()->getResult();
    }
symfony doctrine symfony5
1个回答
0
投票

要解决此错误,您只需添加内连接

->innerjoin('ftch.stat', 'stat')

© www.soinside.com 2019 - 2024. All rights reserved.