How much of the data association model data downloaded by laravel exceeds the number of mysql placeholders?

1. Query the user list and initially change the associated order table, but there are too many users, which causes the mysql placeholder to pass and a mysql error is reported.

2, User::with ("order")-> get ()

error: General error: 1390 Prepared statement contains too many placeholders

select * from order where user_id in (xxx,xxx,.)
because the data associated with the order needs to be looped later.
foreach ($user as $v) {

$order_list = $v->order;
$temp_test = [];
if (count($order_list) > 0) {
    foreach ($order_list as $ov) {
        $temp_test[] = $ov->order_id;
    }
}
$data = [
    "user_id" => $v->user_id,
    "order_id" => implod(",", $temp_test)
];
echo $this->downExcel($data);

}

Feb.28,2021

use chunk .

Menu