PHP Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
PHP Topics
Introduction Introduction
Syntax Syntax
Data Types Data Types
Operators Operators
Control Structures Control Structures
Functions Functions
Pre-defined Function Pre-defined Function
Calendar Functions Calendar Functions
Date and Time Date and Time
Array Functions Array Functions
Array List Array Functions List1
Array Function List Array Functions List2
Math Functions Math Functions
PHP MYSQL Functions PHP Mysql Functions
File Handling File Handling
Error Handling Error Handling
DB Size DB Size
PHP Mail PHP Mail
String Tokens String Tokens
String Functions String Functions
String Functions List String Functions List1
String Functions List2 String Functions List2
Session Functions Session Functions
Cookies Functions Cookies Functions
Form Variables Form Variables
Running PHP from JS Running PHP from JS
Array To JS Array To JS
JS Array Array to PHP
Encryption Encryption
Common Header Common Header
Forums Ask Your Doubts
Scraps More about PHP
Feedback Feedback
 




mysql_unbuffered_query() function for PHP


Tutorials »Php »

Topic

What is mysql_unbuffered_query() function in PHP?
How does mysql_unbuffered_query() works?




Explanation

Mysql function mysql_unbuffered_query() send an SQL query to MySQL, without fetching and buffering the result rows

Syntax

resource mysql_unbuffered_query(string query [, resource link_identifier])

Returns the query handle for SELECT queries, TRUE/FALSE for other queries, or FALSE on failure.

mysql_unbuffered_query() sends a SQL query to MySQL, without fetching and buffering the result rows automatically, as mysql_query() does. This saves a considerable amount of memory with SQL queries that produce large result sets.

It executes the query and returns a resource pointing to the result of the query while MySQL is still working, which means you can start reading the result before the query has finished. When using multiple DB-connects, you have to specify the optional parameter link_identifier.

You cannot use mysql_num_rows() and mysql_data_seek() on a result set returned from mysql_unbuffered_query().

Example:


<?php

$link = mysql_pconnect("mysql_host", "mysql_user", "mysql_password")
or die ("Could not connect");

//select database
if (!mysql_select_db("my_database", $link)) {
echo " ERROR NO: " . mysql_errno($link) . "\n";
}

$sql="select * from my_table";
$result =mysql_unbuffered_query($sql,$link);

// start working with data
while ($row = mysql_fetch_assoc($result)) {
echo $row["field1"];
}
?>



RESULT:

Scripts
Tutorials
Code
Tools


See also: mysql_query().





Other Links

web hosting