Route::get('test', function () {
DB::connection()->enableQueryLog();
// 获取已执行的查询数组
Users::with('posts')->get();
dd(DB::getQueryLog());
});
array:2 [▼
0 => array:3 [▼
"query" => "select * from `users`"
"bindings" => []
"time" => 2.76
]
1 => array:3 [▼
"query" => "select * from `posts` where `posts`.`users_id` in (?, ?)"
"bindings" => array:2 [▶]
"time" => 0.71
]
]
上述代码中 为什么不是select id from user 然后把这个查询结果用于下一步的in中 ,