This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Doctrine implicit join

This is for discussion, mainly on 1.x but there's some 2.x topics here too.

Doctrine implicit join

by ghamirmed » Mon Jul 28, 2014 3:58 pm

Im novice in DQL langage and need same helps about implicit join query like :
Code: Select all
select e from employee e where e.departement.name=?1

or
Code: Select all
select e from employee e where departement.name=?1



Code: Select all
$dm=$this->getDoctrine()->getManager();
        $requete=$dm->createQuery("select e from employee e where e.departement.name=?1");
        $requete->setParameter(1,'sales');


But its not working.

[*]I have a complexe queries to do and i usually use implicits queries in hibernate (HQL).
ghamirmed
Junior Member
 
Posts: 2
Joined: Mon Jul 28, 2014 3:38 pm

Re: Doctrine implicit join

by ghamirmed » Tue Jul 29, 2014 10:02 pm

please i need your help
ghamirmed
Junior Member
 
Posts: 2
Joined: Mon Jul 28, 2014 3:38 pm

Re: Doctrine implicit join

by mickburkesnr » Wed Oct 22, 2014 5:42 pm

Your code is all wrong.

What you should have is along the lines of this:
Code: Select all
      $query = $dm->createQuery('
      SELECT ye.column1, ye.column2
      FROM YourBundle:YourEntity ye
                WHERE ye.column2 = :parameter'
      )->setParameter('parameter', 'value you want to use to search');
      
      $result = $query->getResult();


You can also do it using Doctrine's Query Builder, as outlined here: http://symfony.com/doc/current/book/doc ... ry-builder

What you are trying to do in your code is Native SQL queries, but I don't think you have sufficient understanding of the basics yet to use it.
mickburkesnr
Member
 
Posts: 78
Joined: Mon Aug 22, 2011 12:33 pm
Location: Birmingham, UK