将参数设置为int数组,用于dbal查询生成器中的where语句将数组抛出到字符串转换异常

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

我尝试在WHERE IN语句中的dbal querybuilder中绑定参数:[1,2]

我试图将$qb->expr()->in()更改为字符串版本,但没有任何改变

QueryBuilder创建

$qb = $this->_em->getConnection()->createQueryBuilder()
            ->select('c.id AS id')
            ->from('category', 'c')
            ->andWhere($qb->expr()->in('c.id', ':categories'))->setParameter('categories', [1, 2], \Doctrine\DBAL\Connection::PARAM_INT_ARRAY);

执行:

$qb->execute()->fetchAll();

错误:Array to string conversion

期望将整数数组绑定到querybuilder语句

symfony doctrine-orm doctrine query-builder dbal
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.