Doctrine2查询的内容为:select * from table where column like' 1%'

时间:2014-07-07 07:27:58

标签: symfony

有人可以帮助我在Doctrine中创建查询: 我正在使用:

$repository = $this->getDoctrine()
    ->getRepository('CompanyStoreBundle:Employee');


$employees = $repository->findBy(
    array (), 
    array('nomenklBr' => 'ASC')
    );

...它正在工作,但我想要添加过滤器,所以relsult只包含值为nomenkl-column的记录,以" 1"开头。 谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用dql,如下所示:

    $em = $this->getDoctrine()->getManager();
    $dql = 'SELECT e FROM CompanyStoreBundle:Employee e ORDER BY e.id ASC WHERE e.nomenklBr like "1.%" ';
    $query = $em->createQuery($dql);
    $employees = $query->getResult();