我有很多条件:
if (!empty($requestData['year'])) {
$conditions[] = $qb->expr()->eq('dd.year', $requestData['year']);
}
if(!empty($requestData['month'])){
$conditions[] = $qb->expr()->eq('dd.month', $this->convertMonthStringToNumber($requestData['month']));
}
我正在尝试将其添加到 andWhere 中。我找到了这个解决方案:
$andX = $qb->expr()->andX();
$andX->addMultiple($conditions);
$qb->andWhere($andX);
但这给我带来了一个错误:
assert($lookahead !== null)
in [SERVER]\vendor\doctrine\orm\src\Query\Parser.php (line 2639)
试试这个:
$andX = $qb->expr()->andX(...$conditions);
$qb->andWhere($andX);