Skip to content
Advertisement

Insert limit in local WAMP or XAMPP server

I’m trying to import an excel file with 15,000 record in a local php and mysql system, but it’s always stop inserting in after 3000 records and ignoring the rest of records. Even in the hosted copy of the system it’s insert only 3027 record.

Can I get some help please?

Import csv php script

JavaScript

Insert script

JavaScript

Advertisement

Answer

I think you’re using codeigniter, so i recommend you to use yield (generator in php) and insert_bulk to handle some big data or some huge records to optimize your code and keep your cpu/memory not to leaks or timeout.

Here’s some logic :

  1. Import your csv and store it in generator.
  2. Process your titles, key values from csv in one process,DO NOT store it in array variable except your titles only.
  3. Convert the generator to array, and do your another process.
  4. Do your logic to insert the data and Store your inserted data to generator.
  5. Convert the generator to array and insert it using insert_batch function from codeigniter.

Actually you can combine poin 4 to the poin 2 so you have one process do all the logic and the result is the data you want to insert to the database.

Here’s my simple code how you implement the logic :

JavaScript

UPDATED:

If you’re using mysql, you need to check your max_allowed_packet and check it in your mysql SHOW VARIABLES WHERE Variable_name LIKE '%max_allowed_packet%' and increase or double the value.

Change in the my.ini file by including the single line under [mysqld] or [client] section in your file:

max_allowed_packet=1024M

then restart the MySQL service and you are done. Hope this simple logic help you out of trouble.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement