如何在laravel中运行左外连接SQL查询

时间:2015-03-02 06:37:57

标签: mysql laravel

我无法使用查询构建器在laravel中编写此查询:

```
SELECT pt.name, IF(up.permission_id IS NULL,'false','true') permission
    FROM mercuri_permission_type pt 
    LEFT OUTER JOIN mercuri_user_permission up 
    ON pt.id = up.permission_id AND up.user_id = $user_id
```

1 个答案:

答案 0 :(得分:0)

你应该做多left join来处理这个问题;但我建议你使用doctrine ORM并在doctrine上运行这个查询。为了在Laravel中使用Doctrine,下面的链接很有用:

Getting started doctrine 2 laravel

Working entities doctrine 2

Creating testing doctrine repositories

Using doctrine query language