PHP脚本由于负载过重而停止运行

时间:2012-07-16 02:18:02

标签: php

我有两个while循环,它们显示来自数据库的数据,但由于负载很重,它会停止工作。

请让我知道如何在每个while循环中销毁/清除以前的负载。

**Code Example: this is not an exact code, but take it as example**

for ($aw = 1; $aw <= 150000; $aw++) {

$sql="INSERT INTO say (cname,cno,clocation,email) VALUES ('Fin','0743208899','London','fin1991@live.com')"; 
$result=mysql_query($sql);

}

1 个答案:

答案 0 :(得分:1)

不是运行50,000个查询,而是构建一个查询:

$rows = Array();
for( $aw=1; $aw<=50000; $aw++) $rows[] = "('Fin','0743208899','London','fin1991@live.com')";
mysql_query("INSERT INTO say (cname,cno,clocation.email) VALUES ".implode(",",$rows));