我确实有以下来源:
//$enity = 'Company:CompanyResourceModel';
public function getAll($entity, $filter = null){
$qb = App::DB()->createQueryBuilder();
$data = $qb ->select('r')
->from($entity, 'r')
->where($this->getExpression($qb, $qb->expr()->andX(), $filter))
->getQuery()
->getArrayResult();
if ( is_array($data) && !empty($data) ) {
return $data;
}
return [];
}
其中App :: DB()包含我的EntityManager,而getExpression()来自此处 https://github.com/tarlepp/symfony-flex-backend/blob/c979e816ed5c4d02de2e857885a4b47f7e42d71e/src/Rest/RepositoryHelper.php#L152-L232
但是,我不断收到以下错误消息
Type: Doctrine\ORM\Query\QueryException
Message: [Semantical Error] line 0, col 51 near 'week = ?1': Error: 'week' is not defined.
“周”是表的现有列,在给定的实体中定义为
/**
* @ORM\Column(type="integer")
*/
protected $week;
有人可以告诉我我要去哪里错或者至少可以向我指出正确的方向吗?预先感谢!
答案 0 :(得分:1)
根据评论
您需要引用实体别名为r
的实体属性,例如
->where('r.'.$this->getExpression($qb, $qb->expr()->andX(), $filter))