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
where msisdn
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 = 0;
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.