<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Execute a query that does not prefetch and buffer all data</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.sqlite-udf-encode-binary.html">sqlite_udf_encode_binary</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sqlite-valid.html">sqlite_valid</a></div> <div class="up"><a href="ref.sqlite.html">SQLite Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.sqlite-unbuffered-query" class="refentry"> <div class="refnamediv"> <h1 class="refname">sqlite_unbuffered_query</h1> <h1 class="refname">SQLiteDatabase::unbufferedQuery</h1> <p class="verinfo">(PHP 5 < 5.4.0, PECL sqlite >= 1.0.0)</p><p class="refpurpose"><span class="refname">sqlite_unbuffered_query</span> -- <span class="refname">SQLiteDatabase::unbufferedQuery</span> — <span class="dc-title">Execute a query that does not prefetch and buffer all data</span></p> </div> <div class="refsect1 description" id="refsect1-function.sqlite-unbuffered-query-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>sqlite_unbuffered_query</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$dbhandle</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$result_type</code><span class="initializer"> = SQLITE_BOTH</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_msg</code></span> ]] )</div> <div class="methodsynopsis dc-description"> <span class="type">resource</span> <span class="methodname"><strong>sqlite_unbuffered_query</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span> , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$dbhandle</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$result_type</code><span class="initializer"> = SQLITE_BOTH</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_msg</code></span> ]] )</div> <p class="para rdfs-comment">Object oriented style (method):</p> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><span class="type SQLiteUnbuffered">SQLiteUnbuffered</span></span> <span class="methodname"><strong>SQLiteDatabase::unbufferedQuery</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$query</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$result_type</code><span class="initializer"> = SQLITE_BOTH</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$error_msg</code></span> ]] )</div> <p class="para rdfs-comment"> <span class="function"><strong>sqlite_unbuffered_query()</strong></span> is identical to <span class="function"><a href="function.sqlite-query.html" class="function">sqlite_query()</a></span> except that the result that is returned is a sequential forward-only result set that can only be used to read each row, one after the other. </p> <p class="para"> This function is ideal for generating things such as HTML tables where you only need to process one row at a time and don't need to randomly access the row data. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Functions such as <span class="function"><a href="function.sqlite-seek.html" class="function">sqlite_seek()</a></span>, <span class="function"><a href="function.sqlite-rewind.html" class="function">sqlite_rewind()</a></span>, <span class="function"><a href="function.sqlite-next.html" class="function">sqlite_next()</a></span>, <span class="function"><a href="function.sqlite-current.html" class="function">sqlite_current()</a></span>, and <span class="function"><a href="function.sqlite-num-rows.html" class="function">sqlite_num_rows()</a></span> do not work on result handles returned from <span class="function"><strong>sqlite_unbuffered_query()</strong></span>. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.sqlite-unbuffered-query-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">dbhandle</code></em></span> <dd> <p class="para"> The SQLite Database resource; returned from <span class="function"><a href="function.sqlite-open.html" class="function">sqlite_open()</a></span> when used procedurally. This parameter is not required when using the object-oriented method. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">query</code></em></span> <dd> <p class="para"> The query to be executed. </p> <p class="para"> Data inside the query should be <a href="function.sqlite-escape-string.html" class="link">properly escaped</a>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">result_type</code></em></span> <dd> <p class="para">The optional <em><code class="parameter">result_type</code></em> parameter accepts a constant and determines how the returned array will be indexed. Using <strong><code>SQLITE_ASSOC</code></strong> will return only associative indices (named fields) while <strong><code>SQLITE_NUM</code></strong> will return only numerical indices (ordinal field numbers). <strong><code>SQLITE_BOTH</code></strong> will return both associative and numerical indices. <strong><code>SQLITE_BOTH</code></strong> is the default for this function.</p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">error_msg</code></em></span> <dd> <p class="para"> The specified variable will be filled if an error occurs. This is specially important because SQL syntax errors can't be fetched using the <span class="function"><a href="function.sqlite-last-error.html" class="function">sqlite_last_error()</a></span> function. </p> </dd> </dt> </dl> </p> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">Two alternative syntaxes are supported for compatibility with other database extensions (such as MySQL). The preferred form is the first, where the <em><code class="parameter">dbhandle</code></em> parameter is the first parameter to the function.</span></p></blockquote> </div> <div class="refsect1 returnvalues" id="refsect1-function.sqlite-unbuffered-query-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a result handle or <strong><code>FALSE</code></strong> on failure. </p> <p class="para"> <span class="function"><strong>sqlite_unbuffered_query()</strong></span> returns a sequential forward-only result set that can only be used to read each row, one after the other. </p> </div> <div class="refsect1 changelog" id="refsect1-function.sqlite-unbuffered-query-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.1.0</td> <td> Added the <em><code class="parameter">error_msg</code></em> parameter </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 seealso" id="refsect1-function.sqlite-unbuffered-query-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.sqlite-query.html" class="function" rel="rdfs-seeAlso">sqlite_query()</a> - Executes a query against a given database and returns a result handle</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.sqlite-udf-encode-binary.html">sqlite_udf_encode_binary</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.sqlite-valid.html">sqlite_valid</a></div> <div class="up"><a href="ref.sqlite.html">SQLite Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>