PHP mysqli_free_result() 函数
PHP mysqli_free_result() 函数释放结果内存
( PHP >= 5)
函数原型
mysqli_free_result( result )
参数
参数 | 描述 |
---|---|
result | 必需。由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符 |
返回值
没有返回值
范例
从结果集中取得行,然后释放结果内存
<?php $conn = mysqli_connect("localhost","root","","test"); if (mysqli_connect_errno($conn)) { echo "连接 MySQL 失败: " , mysqli_connect_error(); exit(); } $sql = "SELECT name,url FROM sites ORDER BY alexa"; if ( $rs = mysqli_query($conn,$sql)) { // 一行行获取 while ($row = mysqli_fetch_row( $rs )) { printf ("%s : %s",$row[0],$row[1]); echo "<br>"; } // 释放结果集 mysqli_free_result($rs); } mysqli_close($conn);