长插入查询

时间:2012-07-27 17:51:28

标签: php javascript mysql node.js wamp

我想在我的数据库中插入大约12500行作为游戏服务器的地图。 这是我的脚本生成查询

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 我的客户端脚本可以访问地图的数据,所以我只是将输出粘贴到phpMyAdmin来运行查询。我遇到的问题(我预期)是我的PHP脚本只能运行30秒这是我的错误。

致命错误:第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
到目前为止没有运气...有关如何运行长查询的任何建议,例如这个&gt;?

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

2 个答案:

答案 0 :(得分:3)

我认为您正在寻找的是set_time_limit() http://php.net/manual/en/function.set-time-limit.php

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

答案 1 :(得分:0)

你们有一些非常好的建议,我无法为我的特定应用程序工作。我的解决方案是从node.js执行查询,将sql从我的客户端发送到服务器。而不是使用phpMyAdmin。我确实尝试从我的phpMyadmin脚本中删除时间限制,但它不起作用。我通过websockets传递了查询,但这不是必需的。