我确实有以下来源:
//$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::D B(( 包含我的 EntityManager,getExpression(( 来自这里 https://github.com/tarlepp/symfony-flex-backend/blob/c979e816ed5c4d02de2e857885a4b47f7e42d71e/src/Rest/RepositoryHelper.php#L152-L232
无论如何,我总是收到 folling 错误
Type: DoctrineORMQueryQueryException
Message: [Semantical Error] line 0, col 51 near 'week = ?1': Error: 'week' is not defined.
"week"是我的表的现有列,在给定的enity中定义为
/**
* @ORMColumn(type="integer")
*/
protected $week;
谁能告诉我哪里出错了,或者至少指出我正确的方向? 提前谢谢!
根据评论,
您需要使用实体别名引用实体属性r
例如
->where('r.'.$this->getExpression($qb, $qb->expr()->andX(), $filter))