Symfony 2查询构建器连接

时间:2014-10-24 12:04:55

标签: symfony formbuilder

我在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'

0 个答案:

没有答案