简体   繁体   中英

insert a lot of data to database php

I want insert about 19000 data to mysql database with php , but with load page or cron job just added about 2000 , how can i insert all data

foreach($inventories as $item){
     $this->model->AddInventory($item);
} 

cron job and load page both are basically same thing, cron job just hit the url for you after defined interval of time. in your case there may be the reason of php execution time out (default execution time is 30 seconds), now you have 2 options

  1. increase php max_execution_time in php.ini file
  2. execute your script via command line

I would recommend to use command line, altering max_execution_time is not the right approach

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM