Reputation: 1709
The aim was to prepare and insert a lot of data at once. "Lots of data" means more than 65535 parameters in one query.
So on $pdo->execute() the error from the title is rised.
I read all about similar errors on SO, but everything is about other cases.
Upvotes: 8
Views: 14104
Reputation: 1709
So the problem is in PDO.
PDO stores count of query parameters in the unsigned int, so it can't operate more than 65535 parameters at once.
To workaround this restriction you need to divide your query.
Upvotes: 14
Reputation: 2676
One solution (if you are pushing a PHP array into database with PDO) is to use array_chunk
to split your array into chunks smaller than the int limit, e.g.:
$chunked_new_record_array = array_chunk($new_record_array,65000,true);
foreach ($chunked_new_record_array as $new_record_chunk)
{
//do PDO insertion
}
Upvotes: 11