<HTML ><HEAD ><TITLE >mysql_unbuffered_query</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="MySQL Functions" HREF="ref.mysql.html"><LINK REL="PREVIOUS" TITLE="mysql_thread_id" HREF="function.mysql-thread-id.html"><LINK REL="NEXT" TITLE="Mohawk Software session handler functions" HREF="ref.msession.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mysql-thread-id.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="ref.msession.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.mysql-unbuffered-query" ></A >mysql_unbuffered_query</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN59608" ></A ><P > (PHP 4 >= 4.0.6)</P >mysql_unbuffered_query -- Send an SQL query to MySQL, without fetching and buffering the result rows </DIV ><DIV CLASS="refsect1" ><A NAME="AEN59611" ></A ><H2 >Description</H2 >resource <B CLASS="methodname" >mysql_unbuffered_query</B > ( string query [, resource link_identifier [, int result_mode]])<BR ></BR ><P > <B CLASS="function" >mysql_unbuffered_query()</B > sends a SQL query <TT CLASS="parameter" ><I >query</I ></TT > to MySQL, without fetching and buffering the result rows automatically, as <A HREF="function.mysql-query.html" ><B CLASS="function" >mysql_query()</B ></A > does. On the one hand, this saves a considerable amount of memory with SQL queries that produce large result sets. On the other hand, you can start working on the result set immediately after the first row has been retrieved: you don't have to wait until the complete SQL query has been performed. When using multiple DB-connects, you have to specify the optional parameter <TT CLASS="parameter" ><I >link_identifier</I ></TT >. </P ><P > The optional <TT CLASS="parameter" ><I >result_mode</I ></TT > parameter can be MYSQL_USE_RESULT and MYSQL_STORE_RESULT. It defaults to MYSQL_USE_RESULT, so the result is not buffered. See also <A HREF="function.mysql-query.html" ><B CLASS="function" >mysql_query()</B ></A > for the counterpart of this behaviour. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > The benefits of <B CLASS="function" >mysql_unbuffered_query()</B > come at a cost: You cannot use <A HREF="function.mysql-num-rows.html" ><B CLASS="function" >mysql_num_rows()</B ></A > on a result set returned from <B CLASS="function" >mysql_unbuffered_query()</B >. You also have to fetch all result rows from an unbuffered SQL query, before you can send a new SQL query to MySQL. </P ></BLOCKQUOTE ></DIV ><P > See also: <A HREF="function.mysql-query.html" ><B CLASS="function" >mysql_query()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.mysql-thread-id.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="ref.msession.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mysql_thread_id</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.mysql.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Mohawk Software session handler functions</TD ></TR ></TABLE ></DIV ></BODY ></HTML >