-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders #18
Comments
Thanks for submitting your error. I will add an exception telling users to array chunks their large array if it is over the mysql placeholder limits of 65,535. |
SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders Help me to Solve this please |
You can break your data into smaller chunks. Something like:
|
Thanks
…On Wed, Dec 12, 2018 at 11:35 PM Yada Khov ***@***.***> wrote:
You can break your data into smaller chunks. Something like:
// break data into max size of 200
$chunks = array_chunk($data, 200);
foreach ($chunks as $chunk) {
// Do insert here
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AYis9TUoGMxqagol9nz3Bb38KfNtx42Cks5u4UWDgaJpZM4QQcmC>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @yadakhov I guess I pushed too hard
insert-on-duplicate-key
, cause apparently I hit the limit of MySQL. 😅I'm just posting this here mainly for maybe somebody else who could get carried away with fast bulk insert/updates like me.
I tried to insert ~5,800 rows of 32 columns at once and I got the above error. It seems it's due to the place holders limit of MySQL.
Don't know if you want to, but basically I believe it's possible to fix this limiting the length of the inline
$data
array generating the SQL statement. You could split the array and iterate through it in slots of less than ~65,000 placeholders, or maybe simply raise anException
for "too much data". It seems in fact Eloquent (v5.5
in my case) somehow fails to raise an appropriateException
and keeps trying forever.BTW I fixed the issue limiting my data to ~2,000 rows and it works great, super fast! 🚀
The text was updated successfully, but these errors were encountered: