我正在实体存储库中执行此查询并不断获取
无法在未定义的结果变量上添加条件
但查询根本没有聚合。为什么这种事会发生在我身上?
public function getPersonalizableItemsByOwner(User $owner)
{
$qb = $this
->getEntityManager()
->createQuery('SELECT pi FROM '.$this->getEntityName().' pi WHERE order_id = :owner_id AND (deletedAt IS NULL OR deletedAt > :referenceDate)')
->setParameters(array('owner_id' => $owner->getId(), 'referenceDate' => date('Y-m-d H:i:s')));
return $qb->getResult();
}
PS:我对 Doctrine 知之甚少,我的任务是通过 KnpLabs SoftDeleteable 特征添加软删除支持,但仅限于某些特定情况,因此我无法使用全局可用的过滤器,必须手动实现它。
您不能检查deletedAt 是否为空,而是检查deletedAt 的ID 是否为空。
更改为:deletedAt.id IS NULL
应该修复它。
编辑:今天早上遇到这个错误并修复了它,感谢:http://www.christophe-meneses.fr/article/corriger-l-erreur-request-ritic-uncaught-php-exception-doctrine-orm-query-queryexception-semantical-error-cannot-add-having-condition-非结果变量 http://www.christophe-meneses.fr/article/corriger-l-erreur-request-critical-uncaught-php-exception-doctrine-orm-query-queryexception-semantical-error-cannot-add-having-condition-on-a-non-result-variable
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)