Home >Backend Development >PHP Tutorial >怎么提高执行效率

怎么提高执行效率

WBOY
WBOYOriginal
2016-06-13 11:31:53841browse

如何提高执行效率

<br />for($i=0; $i<count($r); $i++)<br />	{<br />		$var = explode(" ,",$r[$i]);<br />		$barcode = $var[0];<br />		$num = $var[1];<br />		$sql = "insert into `".$t."`(barcode,num) values('".$barcode."','".$num."')";<br />		echo $sql.'<br />';<br />		mysql_query($sql);<br />	}<br />


一共有6000多条记录,如果每条记录都执行insert into,消耗时间很长,超过默认的90s。有无方法提高执行效率?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn