ListBuilder 未使用 createInExpression 进行过滤

问题描述

我已经在 Slack 上问过了,但也许有人会在这里回答。

我想在 adminUI 中过滤列表,这样我就可以只获取我需要的项目,我使用了 createInExpression。我设置的代码是:

if($request->query->get('team') !== null)
{
    $team = $this->teamsRepository->findById($request->query->get('team'),$request->getLocale());
    if($team)
    {
        $teamPlayers = $team->getTeamPlayers();
        $listBuilder->createInExpression($fieldDescriptors['id'],$teamPlayers);
    }
}

当我调试时,我得到:

$teamPlayers = [ 1 ] << I wanted this,it is correct

而且,当我看到 Doctrine sql-s 的作用时,我发现 DOCTRINE 构建查询如下:

…WHERE p1_.id IN (?),and parameters is [ 1,2,3 ] << this is wrong

有人可以帮助为什么会发生这种情况,以及我如何实现所需的过滤器...

解决方法

好的,我发现问题了。

看起来不太好。 $listBuilder->createInExpression() 只创建它,不应用它,我只需要调用:

$listBuilder->in($fieldDescriptors['id'],$teamPlayers);

现在一切正常...

抱歉耽误了时间..