Reputation: 21
I have used following code for simple join in Doctriner in Codeigniter:
$query = $this->em->createQuery('SELECT u.name,u.subject,pds.subject_name FROM PdContact u,PdSubject pds WHERE pds.id=u.sub_id');
But how to do left join? When I tried to to left join it shows error.
Please suggest solution.
Upvotes: 1
Views: 54
Reputation: 2263
You can use this :
$sql = "SELECT u.name,u.subject,pds.subject_name FROM PdContact u LEFT JOIN PdSubject pds ON pds.id=u.sub_id;";
$connection = $this->em->getConnection();
$cleanreq = $connection->prepare($sql);
$cleanreq->execute();
$result = $cleanreq->fetchAll();
return $result;
For more infos on Joining you can check this doc : http://doctrine-orm.readthedocs.org/en/latest/reference/dql-doctrine-query-language.html
Upvotes: 1