Home >Database >Mysql Tutorial >mysql释放结果内存代码示例

mysql释放结果内存代码示例

PHPz
PHPzOriginal
2016-06-07 16:20:561625browse

mysql释放结果内存代码示例(相关mysql视频教程推荐:《mysql教程》)

定义和用法

mysql_free_result() 函数释放结果内存。

如果成功,则返回 true,如果失败,,则返回 false。

语法

mysql_free_result(data)参数 描述

data 必需。要释放的结果标识符。该结果标识符是从 mysql_query() 返回的结果。

提示和注释

注释:mysql_free_result() 仅需要在考虑到返回很大的结果集时会占用多少内存时调用。在脚本结束后所有关联的内存都会被自动释放。

例子

$con = mysql_connect("localhost", "peter", "abc123");
  if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  $db_selected = mysql_select_db("test_db",$con);
  $sql = "SELECT * from Person";
  $result = mysql_query($sql,$con);
  print_r(mysql_fetch_row($result));
  // 释放内存
  mysql_free_result($result);
  $sql = "SELECT * from Customers";
  $result = mysql_query($sql,$con);
  print_r(mysql_fetch_row($result));
  mysql_close($con);
  ?>

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