我在Repository.php文件中写了这个函数:
PermitsRepository :
public function findPermits($permitId, $permitname, $permitsurname, $company, $contractor, $date) {
$qb = $this->createQueryBuilder('e');
$query = $qb->where('e.Permitid like :permitid and e.Permitname like :permitname and e.Permitsurname like :permitsurname and c.name like:company and r.name like:contractor and e.expirationdate like :date')
->setParameter('permitid','%'.$permitId.'%')
->setParameter('permitname','%'.$permitname.'%')
->setParameter('permitsurname','%'.$permitsurname.'%')
->setParameter('company','%'.$company.'%')
->setParameter('contractor','%'.$contractor.'%')
->setParameter('date','%'.$date.'%')
->join('e.PermitsCompany', 'c')
->join('e.PermitsContractor', 'r');
$query->orderBy('e.id', 'DESC');
return $query->getQuery();
}
关键是我要加入两张桌子。 公司和承包商, 此 PermitsCompany 和 PermitsContractor 是表 Permits 和 Company 以及 Contractor 之间的连接。
在查询中,我想从表公司和承包商获取NAME行。
c.name like:company
and r.name like:contractor
但是我收到了错误:
[Syntax Error] line 0, col 228: Error: Expected =, <, <=, <>, >, >=, !=, got 'like:company'