zend_db 查询到学说 2 querybuilder 转换

zend_db query to doctrine 2 querybuilder conversion

在 dbTable 中我有

 ->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'),

在学说查询生成器中我有

-

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

但我不知道如何在左连接子句中添加 AND 条件

帮帮我

如果在 LEFT JOIN 子句中严格需要 AND 条件,则应使用原则 nativeQuery 方法。

但这不会奏效吗?

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

我猜 UserProject 是 Doctrine 实体,所以你应该在你的 where 子句中使用实体定义。

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