Php 雄辩的补充';为空';左联接后的何处查询

Php 雄辩的补充';为空';左联接后的何处查询,php,sql,laravel,laravel-4,eloquent,Php,Sql,Laravel,Laravel 4,Eloquent,以下是我雄辩的问题: $table = DB::table('invites') ->leftjoin('connections', 'connections.user_id', '=', 'invites.user_id') ->where(DB::raw('connections.firm_id = invites.firm_id')) ->get(); 它应该返回一个与邀请他们的公司有联系的用户表 查询日志显示执行了以下查询:

以下是我雄辩的问题:

$table =  DB::table('invites')
       ->leftjoin('connections', 'connections.user_id', '=', 'invites.user_id')
       ->where(DB::raw('connections.firm_id = invites.firm_id'))
       ->get();
它应该返回一个与邀请他们的公司有联系的用户表

查询日志显示执行了以下查询:

'query' => 'select * from `invites` left join `connections` on `connections`.`user_id` = `invites`.`user_id` where connections.firm_id = invites.firm_id is null'
最后的
是空的
把一切都搞糟了。我假设这与以下事实有关:列名称相同,或者我是否缺少DB::raw?

where()方法将列名称作为第一个参数,如果缺少下一个参数,则将其视为where column is null约束-这就是为什么会得到如此奇怪的查询。改用whereRaw()

->whereRaw('connections.firm_id = invites.firm_id')
where()方法将列名作为第一个参数,如果缺少下一个参数,则将其视为where column is null约束-这就是为什么您会得到如此奇怪的查询。改用whereRaw()

->whereRaw('connections.firm_id = invites.firm_id')

帮我省了点麻烦,省了点麻烦。