I have a simple query like this:
$arp_terhadap_st_reg = Sfs::select('msisdn')
->wherebetween('created', [$datefrom, $dateto])
->where('cluster', $cluster)
->pluck('msisdn');
$arp_outlet_reg = Arps::whereIn('msisdn', $arp_terhadap_st_reg)
->count();
Here, $idList
is an array, which contains user id, and I have more than 60000 ids.
Everytime, code tells me:
"error": {
"type": "Exception",
"message": "SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders
SQL: select count(*) as aggregate from
arps
wheremsisdn
in (?, ?, ?, ?,...................
A lot of ? ...
So, how can I fix this problem. Thanks.
Use array_chunk
like below
$arp_terhadap_st_reg = Sfs::select('msisdn')
->wherebetween('created', [$datefrom, $dateto])
->where('cluster', $cluster)
->get()
->toArray();
$arp_outlet_count =
foreach (array_chunk($arp_terhadap_st_reg, 1000) as $arp_terhadap_st) {
$arp_outlet_reg = Arps::whereIn('msisdn', $arp_terhadap_st)->count();
$arp_outlet_count = $arp_outlet_count + $arp_outlet_reg;
}
You will get your total count in $arp_outlet_count