0
如何在控制器中劃分查詢?如何在控制器中劃分查詢?
我:
private function getPeoples($andWhere = null)
{
$peoples = $this->getDoctrine()
->getRepository('AcmeDemoBundle:People')
->createQueryBuilder('p')
->getQuery()
->getResult();
return $peoples;
}
這工作不錯,但我想添加這個IF和andWhere:
private function getPeoples($andWhere = null)
{
$peoples = $this->getDoctrine()
->getRepository('AcmeDemoBundle:People')
->createQueryBuilder('p');
if($andWhere == true){
$peoples->andWhere('p.test > 5');
}
$peoples->getQuery()
->getResult();
return $peoples;
}
但這不工作 - 對象不是空的,但沒有數據。爲什麼?在Symfony 1中這個工作。我如何使它在Symfony2中?
哈哈,我是有點快。 ;) – lxg 2014-09-03 18:29:45
hehe是的,這是真的:) – takeit 2014-09-03 18:32:14