我们如何编写PHP脚本来释放与MySQL结果相关的游标内存?
众所周知,PHP使用msql_free_result()函数释放与MySQL结果相关的游标内存。为了说明这一点,我们有以下示例-
示例
在此示例中,我们正在编写以下PHP脚本,该脚本将从名为“ Tutorials_tbl”的表中获取记录后释放内存。
<?php$dbhost = 'localhost:3036';
$dbuser = 'root';
$dbpass = 'rootpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT tutorial_id, tutorial_title, tutorial_author, submission_date
FROM tutorials_tbl';
mysql_select_db('TUTORIALS');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_NUM)) {
echo "Tutorial ID :{$row[0]} <br> ".
"Title: {$row[1]} <br> ".
"Author: {$row[2]} <br> ".
"Submission Date : {$row[3]} <br> ".
"--------------------------------<br>";
}
mysql_free_result($retval);
echo "Fetched data successfully\n";
mysql_close($conn);
?>
以上是 我们如何编写PHP脚本来释放与MySQL结果相关的游标内存? 的全部内容, 来源链接: utcz.com/z/352573.html