Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDOException: SQLSTATE[HY000]: General error: 7 number of parameters must be between 0 and 65535

Tags:

php

pdo

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.

like image 611
Funcraft Avatar asked Dec 10 '22 14:12

Funcraft


1 Answers

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.

like image 69
Funcraft Avatar answered Feb 01 '23 23:02

Funcraft