w3resource logo


PHP mysql_unbuffered_query function

PHP : mysql_unbuffered_query() function

rating has average rating 9 out of 10. Total 1 users rated.

<<PreviousNext>>

Description

The mysql_unbuffered_query () sends an SQL query to MySQL, without fetching and buffering the result rows. The benefit of using this function is that it saves considerable amount of memory with SQL queries that produce large result sets and you can start working immediately without waiting for the entire sql query to be completed.

Version

(PHP 4 and above)

Syntax

mysql_unbuffered_query(query, connection)

Parameters

Name Description Required/ Optional Type
query A SQL query. Required String
connection The MySQL connection. Before performing any operation on a MySQL database, it is required to set a connection to the mysql database you want to work with. And this is done by mysql_connect() function. This function takes three parameters, name of the host, username with which you want to perform tasks with the mysql database in question, and password of that user. As soon as a successful connection is established, you can perform the operations on that mysql database. In case, no such connection is found, it will try to create one without any arguments, i.e. mysql_connect() without any parameters. If it fails to connect to a mysql database, it will generate a warning (E_WARNING) but not an error. Optional Resource

Return value

Query handle for successful SELECT, SHOW, DESCRIBE, EXPLAIN and other statements (UPDATE, DELETE, DROP, etc,) or FALSE on error.

Value Type : Resource.

Example :

<?php
$con = mysql_connect("localhost","root","mypass");
$sql = "SELECT * FROM tutorials";
mysql_unbuffered_query($sql,$con);
mysql_close($con);
?>

See also

PHP Function Reference

mysql_query()

<<PreviousNext>>

Rate this tutorial


Your Rating: not set

Share this tutorial

RSS Feed