Waqar Haider
Waqar Haider

Reputation: 973

zend_db query to doctrine 2 querybuilder conversion

in dbTable i have

 ->joinLeft(array('user_roles' => 'user_roles'),
     'user_roles.user_id = users.user_id AND user_roles.project_id = projects.project_id', null)
                            ->joinLeft(array('roles' => 'roles'),

and in doctrine query builder i have

-

>join('users.userRole','userRole')
        ->leftJoin('userRole.role','role')
        ->where('project.projectId = :project')

but i dont know how to add AND condition in left join clause

help me someone

Upvotes: 0

Views: 37

Answers (1)

ceadreak
ceadreak

Reputation: 1684

If you need an AND condition strictly in the LEFT JOIN clause, you should use the doctrine nativeQuery method.

But this will do the trick no ?

->join('users.userRole','userRole')
->leftJoin('userRole.role','role', 'WITH', 'user_roles.user_id = users.user_id')
->where('project.projectId = :project')

I guess User and Project are Doctrine entities so you should use entity definition in your where clauses.

->where('project = :project') // where project is an instance of Project

Upvotes: 2

Related Questions