我在某些页面上有大量查询(一行约30个字段)。我听说mysql_free_result可以提高内存性能。现在我想问你,我怎样才能正确使用mysql_free_result。
我在班上的确喜欢这样:
// buffered query
private function query($queryStr)
{
$this->querycount++;
$starttime = microtime();
$this->queryRes = mysql_query($queryStr, $this->conn);
$this->querytime = $this->querytime + (microtime() - $starttime);
if ($this->queryRes)
{
$this->query_log($queryStr,$this->querytime);
}
else
{
$this->error("SQL ERROR: " . $queryStr);
}
return $this->queryRes;
$this->free_result($this->queryRes);
}
// free result
public function free_result($result)
{
mysql_free_result($result);
}
这是真的吗?如果不是,我该如何正确使用?
答案 0 :(得分:1)
在脚本执行结束时自动释放所有关联的结果存储器。
在你的情况下它看起来不太好,因为你的函数正在返回$this->queryRes;
,它将无法进入下一步。
答案 1 :(得分:0)
如何正确使用mysql_free_result。
不要使用它。