Select whereExist 中的所有表值 - Laravel

Select all tables values inside whereExist - Laravel

我还需要 select 其他几列,而不仅仅是前 table 列。我有代码;

$records_all = DB::table('table1')
    ->whereExists(function($query) use ($date) {
           $query->select(DB::raw(1))
                 ->from('table2')
                 ->whereRaw('table2.table1_id = table1.table1_id')
                 ->whereNotExists(function($query) use ($date) {
                      $query->select(DB::raw(1))
                            ->from('table3')
                            ->whereRaw('table2.table2_id = table3.table2_id')
                            ->whereRaw("DATE(table3.date)='" . $date . "'");
                 });
  })
  ->orderBy('url')
  ->get();

这会在需要时为我提供 table1 的记录。但是如何从 table2 或 table3 得到任何东西?

我正在使用 laravel 4.2

感谢您的帮助。

将 DB::raw(1) 更改为您需要的特定列并用逗号分隔列

$records_all = DB::table(DB::raw('table1, table2, table3'))
    ->select('table1.*','table2.table2_id','table3.table3_id')
    ->whereExists(function($query) use ($date) {
        $query->from('table2')
        ->whereRaw('table2.table1_id = table1.table1_id')
        ->whereNotExists(function($query) use ($date) {
            $query->from('table3')
            ->whereRaw('table2.table2_id = table3.table2_id')
            ->whereRaw("DATE(table3.date)='" . $date . "'");
        });
    })
    ->orderBy('url')
    ->get();

在上述语句之后打印上次执行的查询

$queries = DB::getQueryLog();
$last_query = end($queries);
print_r($last_query);exit;