简体   繁体   English

向数据库php插入大量数据

[英]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我想用 php 向 mysql 数据库插入大约 19000 条数据,但是加载页面或 cron 作业刚刚添加了大约 2000 条数据,我如何插入所有数据

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. cron job 和 load page 基本上是一样的,cron job 只是在定义的时间间隔后为你点击 url。 in your case there may be the reason of php execution time out (default execution time is 30 seconds), now you have 2 options在您的情况下,可能是 php 执行超时的原因(默认执行时间为 30 秒),现在您有 2 个选项

  1. increase php max_execution_time in php.ini file在 php.ini 文件中增加 php max_execution_time
  2. execute your script via command line通过命令行执行你的脚本

I would recommend to use command line, altering max_execution_time is not the right approach我建议使用命令行,改变 max_execution_time 不是正确的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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