mysqli_stmt::free_result
(mysqli_stmt_free_result) Release the memory of the storage result of the given statement handle.
Function name: mysqli_stmt::free_result()
Function Description: This function is used to release the result set related to the preprocessing statement.
Applicable version: PHP 5, PHP 7
Syntax: mysqli_stmt::free_result()
Parameters: No parameters.
Return value: This function does not return value.
Example:
<?php // 创建数据库连接$mysqli = new mysqli("localhost", "username", "password", "database"); // 检查连接是否成功if ($mysqli->connect_error) { die("连接失败: " . $mysqli->connect_error); } // 准备预处理语句$stmt = $mysqli->prepare("SELECT id, name FROM users WHERE age > ?"); // 绑定参数$age = 18; $stmt->bind_param("i", $age); // 执行查询$stmt->execute(); // 绑定结果$stmt->bind_result($id, $name); // 输出结果while ($stmt->fetch()) { echo "ID: " . $id . ", Name: " . $name . "<br>"; } // 释放结果集$stmt->free_result(); // 关闭预处理语句和数据库连接$stmt->close(); $mysqli->close(); ?>
illustrate: