dongyue8640 2010-07-09 07:31
浏览 28
已采纳

将包含50,000多个条目的数组转换为mysql数据库

Ok, so I am helping someone with their site. Their original coder thought it would be a great idea to put their entire database in an array.

I am looping through each piece of data in the array and inserting it into a new mysql table I created, the rows are getting inserted just fine but the problem is that php wont let my script execute for more than 60 seconds.

How can I override this setting?

  • 写回答

5条回答 默认 最新

  • dounei9043 2010-07-09 07:35
    关注

    There's the classic solution, using set_time_limit(), which allows you to set the maximum execution time (in seconds) for a script.

    Still, you might want to either insert multiple rows with one query or convert the array into CSV and use LOAD DATA which is much faster.

    Edit: examples

    Inserting multiple rows:

    INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
    

    Ref: http://dev.mysql.com/doc/refman/5.1/en/insert.html

    Using LOAD DATA:

    LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
    

    Ref: http://dev.mysql.com/doc/refman/5.1/en/load-data.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题