2015-05-04 69 views
0

我都试过,但它不会工作,它只是执行第一实体我怎样才能得到许多实体库在一个getRepository

$resultat = $con->getRepository("PFESiivtBundle:Categorie","PFESiivtBundle:Evenement", 
"PFESiivtBundle:Projet")->findBy(array('idPublication' =>$respub),array('id'=>'DESC')); 
+0

你不能,你应该用你的实体 –

+0

之间的连接紧密究竟怎么了? easly –

回答

2

你的做法是行不通的,你应该创建一个Repository然后加入你的表格,

class CategorieRepository extends EntityRepository 
{ 
    public function getCategorieRelatedDataByIdAndIdPublication($idPublication) 
    { 
     $qb = $this->entityManager->createQueryBuilder(); 
     $qb->select('c', 'e', 'p') 
     ->from('PFESiivtBundle:Categorie', 'c') 
     ->leftJoin('c.eveniment', 'e') 
     ->leftJoin('c.project', 'p') 
     ->where('c.id = :id') 
     ->andWhere('c.idPublication = :id_publication') 
     ->setParameter('id_publication', $idPublication) 

     return $qb->getQuery()->getResult(); 
    } 
} 

连接将取决于你的映射,没有映射结构我不能给你正确的代码。

然后在Controller你如下使用:

$resultat = $con->getRepository("PFESiivtBundle:Categorie")-> getCategorieRelatedDataByIdAndIdPublication($idPublication);

+0

非常感谢你! –