php - 长插入查询

标签 php javascript mysql node.js wamp

我想在我的数据库中插入大约 12500 行以获取游戏服务器的 map 。 这是我的脚本生成查询

sql = "INSERT INTO `legends`.`map` (`x`, `y`, `land`, `collision`, `impedance`, `effect`) VALUES "
for (y=0;y<ig.game.collisionMap.data.length;y++){
   for (x=0;x<ig.game.collisionMap.data[y].length;x++){
      if (x==0&&y==0){
         comma=""
      }else{
         comma=","
      }
      sql=sql+comma+"("+x*55+","+y*55+",'kesmai',"+ig.game.collisionMap.data[y][x]+","+ig.game.backgroundMaps[0].data[y][x]+", '0')";
   }
}
console.log(sql)

输出为 y=86 x=145 我的客户端脚本可以访问 map 数据,所以我只是将输出粘贴到 phpMyAdmin 以运行查询。我遇到的问题(如我所料)是我的 php 脚本只能运行 30 秒,这是我的错误。

fatal error :第 92 行 C:\wamp\apps\phpmyadmin3.4.10.1\libraries\session.inc.php 中超过 30 秒的最大执行时间

我正在运行一个 WAMP 服务器,我试图在这里编辑我的 php.ini 文件

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 0

; Maximum amount of time each script may spend parsing request data. It's a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts. 
; Note: This directive is hardcoded to -1 for the CLI SAPI
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
; http://php.net/max-input-time
max_input_time = -1

到目前为止运气不好......关于如何运行像这样的长查询有什么建议>?

我正在考虑暂时将它放在我在 node.js 中运行的服务器脚本中

最佳答案

我想你要找的是 set_time_limit() http://php.net/manual/en/function.set-time-limit.php

但是您应该看看是否有任何方法可以提高查询本身的性能。

关于php - 长插入查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11693062/

相关文章:

php - 在 Drupal 中自定义 WebForm 模块

php - "session_regenerate_id(): Cannot regenerate session id - headers already sent"如何解决

php - 使用PHP的exec进行Ghostscript PDF文件压缩(Docker上的Laravel)

javascript - 如何在 hapi.js 路由处理程序中将 mongodb 信息返回到浏览器?

mysql - sql左连接限制子查询

mysql - 将Access数据库表中的记录一一插入/复制到MySQL远程数据库

php - 将数据插入 Wordpress 数据库时出错。 SQLSTATE[HY093] : Invalid parameter number

javascript - ios-deploy 安装失败

javascript - React 中太多的重新渲染

C#.NET - 无法添加或更新子行 : a foreign key constraint fails