-1
我遇到了这个查询问题。我想获得只与属性附加伤害$ categoria的车,我这样做:教义和问题
public function listcategoriaAction($categoria)
{
$posts = $this->get('doctrine')->getManager()->createQueryBuilder()->select('p')->from('CarsCarsBundle:Post', 'p')->where('p.categoria = :categoria')->setParameter('categoria', $categoria)->getQuery()->getResult();
return $this->render('CarsCarsBundle:Cars:list.html.twig', array('posts' => $posts));
}
但是我收到一个空数组。任何提示将不胜感激
你能告诉如果$ categoria参数是Categoria对象或外键值(即分类的ID)? –