Home > Backend Development > PHP Problem > How to use php mysqli_free_result function

How to use php mysqli_free_result function

藏色散人
Release: 2023-02-22 19:44:01
Original
3249 people have browsed it

php The mysqli_free_result function is used to release the result memory. Its syntax is mysqli_free_result(result). The parameter result is required and there is no return value.

How to use php mysqli_free_result function

php How to use the mysqli_free_result function?

Definition and usage

mysqli_free_result() function releases the result memory.

Syntax

mysqli_free_result(result);
Copy after login

Parameters

result Required. Specifies the result set identifier returned by mysqli_query(), mysqli_store_result(), or mysqli_use_result().

Return value: No return value.

PHP version: 5

Get rows from the result set and then release the result memory:

<?php 
// 假定数据库用户名:root,密码:123456,数据库:RUNOOB 
$con=mysqli_connect("localhost","root","123456","RUNOOB"); 
if (mysqli_connect_errno($con)) 
{ 
    echo "连接 MySQL 失败: " . mysqli_connect_error(); 
} 
 
$sql="SELECT name,url FROM websites ORDER BY alexa";
 
if ($result=mysqli_query($con,$sql))
{
    // 一行行获取
    while ($row=mysqli_fetch_row($result))
    {
        printf ("%s : %s",$row[0],$row[1]);
        echo "<br>";
    }
    // 释放结果集
    mysqli_free_result($result);
}
 
mysqli_close($con);
?>
Copy after login

The above is the detailed content of How to use php mysqli_free_result function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template