当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > mysql_unbuffered_query() 函数

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
用PHP5的DirectoryIterators递归扫描目录
PHP 阻止SQL注入式攻击
PHP5面向对象 - 基础 - 类和对象
PHP5面向对象 - 基础 - 类的属性( public )
PHP5面向对象 - 基础 - 类的属性( private )
PHP5面向对象 - 基础 - 方法
PHP5面向对象 - 基础 - 对象的比较
php5面向对象 - 基础 - 构造函数
php5面向对象 - 基础 - 析构函数
用PHP控制用户的浏览器 - ob*函数的使用
PHP PDO 学习笔记

PHP 中的 mysql_unbuffered_query() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 512 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The mysql_unbuffered_query() function executes a query on a MySQL database.
mysql_unbuffered_query()函数的作用是:向 MySQL数据库发送一条 SQL 查询,并不获取和缓存结果的行。

Unlike mysql_query(), this function does not fetch and buffer the recordset automatically. This saves some memory with large SQL queries, and you can start working on the result set immediately after the first row has been retrieved.
与mysql_query()函数不同,mysql_unbuffered_query()函数将不会自动获取记录,也不会自动对其进行缓冲。它存储了一些通过使用大量SQL查询语句执行的结果;你可以在获取第一行的值以后直接对结果进行设置。

This function returns the query handle for SELECT queries, TRUE/FALSE for other queries, or FALSE on failure.
如果函数执行成功,它将返回True,并通过SELECT查询语句返回查询结果;如果函数执行失败,将返回False。

Syntax
语法

mysql_unbuffered_query(query,connection)

Parameter参数 Description描述
query Required. Specifies the SQL query to send (should not end with a semicolon)
必要参数。指定需要发送的SQL查询语句(不可以以分号“;”结束)
connection Optional. Specifies the MySQL connection. If not specified, the last connection opened by mysql_connect() or mysql_pconnect() is used.
可选参数。指定MySQL连接。如果不指定该参数,那将默认使用通过mysql_connect()函数或mysql_pconnect()函数最后一次打开的连接


Tips and Notes
注意点:

Note: The benefits of mysql_unbuffered_query() come at a cost: You cannot use mysql_num_rows() and mysql_data_seek() on a result set returned from mysql_unbuffered_query().
注意:使用mysql_unbuffered_query()函数也会存在弊端:你不可以使用mysql_num_rows() 和 mysql_data_seek()对使用mysql_unbuffered_query()返回的结果属性进行操作。


Example
案例

<?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con) { die('Could not connect: ' . mysql_error()); }
// Large query
$sql = "SELECT * FROM Person";
mysql_unbuffered_query($sql,$con);
// start working with data
mysql_close($con);
?>

评论 (0) All

登陆 | 还没注册?