I have two table in my database and i want to join this 2 table to show data in my view but i didn't find a solution.
This is my first entity given below
/** * @ORM\Entity */ class classified { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $classified_id; /** * @ORM\Column(type="integer") */ protected $user_id=0; /** * @ORM\Column(type="string") */ protected $firstname="null"; /** * @ORM\Column(type="integer") */ protected $region_id="null"; The second entity :
class regions { /** * @ORM\Id * @ORM\Column(type="integer") */ protected $region_id; /** * @ORM\Column(type="string") */ protected $regionname; /** * @ORM\Column(type="integer") */ protected $country_id=107; } In my controller i would like to join the table to get information.
$em = $this->getDoctrine() ->getEntityManager(); $classified = $em->createQueryBuilder() ->select('b') ->from('BlogBundle:classified', 'b') ->addOrderBy('b.classifiedaddeddate', 'DESC') ->getQuery() ->getResult(); return $this->render('BlogBundle:Page:index.html.twig', array( 'classified' => $classified )); Any solution please?