php递归导致内存不够
<br />$user = 'root';<br />$pass = 'thrope';<br />$dbh = new PDO('mysql:host=localhost;dbname=income', $user, $pass);<br />$query = 'insert into picinfo set picpath=:pp, picsize=:ps';//把文件路径和文件大小写入数据库<br />$stmt = $dbh->prepare($query);<br /><br />function dir_read($dir){<br /> $dh = opendir($dir);//if (is_dir($dir)) echo realpath($dir).'<br/>';<br /> while (false !== ($filename = readdir($dh))){//echo realpath($dir.'/'.$filename).'<br/>';<br /> //if ($filename == '.' || $filename == '..') continue;<br /> if (is_file($dir.'/'.$filename)){<br /> global $stmt;<br /> $stmt->execute(array(':pp'=>realpath($dir.'/'.$filename), ':ps'=>filesize(realpath($dir.'/'.$filename))));<br /> //echo $dbh->errorCode();<br /> }<br /> if (is_dir(realpath($dir.'/'.$filename)))//这个递归调用特别耗费资源<br /> dir_read(realpath($dir.'/'.$filename));<br /> <br /> }<br /> closedir($dh);<br />}<br /><br />dir_read('K:/project/fileOperate');<br />