array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.mysql-free-result.php', 1 => 'mysql_free_result', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'MySQL 函数', ), 'prev' => array ( 0 => 'function.mysql-field-type.php', 1 => 'mysql_field_type', ), 'next' => array ( 0 => 'function.mysql-get-client-info.php', 1 => 'mysql_get_client_info', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/mysql/functions/mysql-free-result.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5)
mysql_free_result — 释放结果内存
本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLi 或 PDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:
null
to the PDO object, or PDOStatement::closeCursor()
mysql_free_result() 将释放所有与结果标识符
result
所关联的内存。
mysql_free_result() 仅需要在考虑到返回很大的结果集时会占用多少内存时调用。在脚本结束后所有关联的内存都会被自动释放。
为向下兼容仍然可以使用 mysql_freeresult(),但反对这样做。
If a non-resource is used for the result
, an
error of level E_WARNING will be emitted. It's worth noting that
mysql_query() only returns a resource
for SELECT, SHOW, EXPLAIN, and DESCRIBE queries.
示例 #1 A mysql_free_result() example
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
/* Use the result, assuming we're done with it afterwards */
$row = mysql_fetch_assoc($result);
/* Now we free up the result and continue on with our script */
mysql_free_result($result);
echo $row['id'];
echo $row['email'];
?>
注意:
为了向下兼容,可以使用下列已废弃的别名: mysql_freeresult()