Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
$orderId = 1; DB::table('users') ->whereIn("user_id",function($query) { $query->select("user_id")->from('orders')->where('orders.id','>',$orderId); }) ->get();
我想使用$orderId,但它不起作用,我该怎么办?
你不需要传递$orderId到闭包中 - 像这样
$orderId
$orderId = 1; DB::table('users') ->whereIn("user_id",function($query) use ($orderId) { $query->select("user_id")->from('orders')->where('orders.id','>',$orderId); }) ->get();