downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.sqlite-fetch-all.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.sqlite.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.sqlite-fetch-all.php',
   
1 => 'sqlite_fetch_all',
  ),
 
'up' =>
  array (
   
0 => 'ref.sqlite.php',
   
1 => 'SQLite Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.sqlite-factory.php',
   
1 => 'sqlite_factory',
  ),
 
'next' =>
  array (
   
0 => 'function.sqlite-fetch-array.php',
   
1 => 'sqlite_fetch_array',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.sqlite-fetch-all" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlite_fetch_all</h1>
  <h1 class="refname">SQLiteResult-&gt;fetchAll</h1>
  <h1 class="refname">SQLiteUnbuffered-&gt;fetchAll</h1>
  <p class="verinfo">(PHP 5, PECL sqlite &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">sqlite_fetch_all</span> -- <span class="refname">SQLiteResult-&gt;fetchAll</span> -- <span class="refname">SQLiteUnbuffered-&gt;fetchAll</span> &mdash; <span class="dc-title">Fetches all rows from a result set as an array of arrays</span></p>

 </div>

 <a name="function.sqlite-fetch-all.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><b>sqlite_fetch_all</b></span>
    ( <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$result</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$result_type</tt><span class="initializer"> = SQLITE_BOTH</span></span>
   [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$decode_binary</tt><span class="initializer"> = true</span></span>
  ]] )</div>

  <p class="para rdfs-comment">Object oriented style (method):</p>
  <div class="classsynopsis">
   <div class="ooclass"><b class="classname">SQLiteResult</b></div>
   <div class="methodsynopsis dc-description">
    <span class="type">array</span> <span class="methodname"><b>fetchAll</b></span>
     ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$result_type</tt><span class="initializer"> = SQLITE_BOTH</span></span>
    [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$decode_binary</tt><span class="initializer"> = true</span></span>
   ]] )</div>

  </div>
  <div class="classsynopsis">
   <div class="ooclass"><b class="classname">SQLiteUnbuffered</b></div>
   <div class="methodsynopsis dc-description">
    <span class="type">array</span> <span class="methodname"><b>fetchAll</b></span>
     ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$result_type</tt><span class="initializer"> = SQLITE_BOTH</span></span>
    [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$decode_binary</tt><span class="initializer"> = true</span></span>
   ]] )</div>

  </div>
  <p class="para">
   <b>sqlite_fetch_all()</b> returns an array of the entire result
   set from the <i><tt class="parameter">result</tt></i>
 resource.  It is similar to calling
   <a href="function.sqlite-query.php" class="function">sqlite_query()</a> (or
   <a href="function.sqlite-unbuffered-query.php" class="function">sqlite_unbuffered_query()</a>) and then
   <a href="function.sqlite-fetch-array.php" class="function">sqlite_fetch_array()</a> for each row in the result set.
  </p>
 </div>


 <a name="function.sqlite-fetch-all.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">result</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The SQLite result resource.  This parameter is not required when using
       the object-oriented method.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">result_type</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">The optional <i><tt class="parameter">result_type</tt></i>

parameter accepts a constant and determines how the returned array will be
indexed. Using <b><tt class="constant">SQLITE_ASSOC</tt></b> will return only associative
indices (named fields) while <b><tt class="constant">SQLITE_NUM</tt></b> will return
only numerical indices (ordinal field numbers). <b><tt class="constant">SQLITE_BOTH</tt></b>
will return both associative and numerical indices.
<b><tt class="constant">SQLITE_BOTH</tt></b> is the default for this function.</p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">decode_binary</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">When the <i><tt class="parameter">decode_binary</tt></i>

parameter is set to <b><tt class="constant">TRUE</tt></b> (the default), PHP will decode the binary encoding
it applied to the data if it was encoded using the
<a href="function.sqlite-escape-string.php" class="function">sqlite_escape_string()</a>.  You should normally leave this
value at its default, unless you are interoperating with databases created by
other sqlite capable applications.</p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.sqlite-fetch-all.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an array of the remaining rows in a result set. If called right
   after <a href="function.sqlite-query.php" class="function">sqlite_query()</a>, it returns all rows. If called
   after <a href="function.sqlite-fetch-array.php" class="function">sqlite_fetch_array()</a>, it returns the rest. If
   there are no rows in a result set, it returns an empty array.
  </p>
  <p class="para">The column names returned by
<b><tt class="constant">SQLITE_ASSOC</tt></b> and <b><tt class="constant">SQLITE_BOTH</tt></b> will be
case-folded according to the value of the
<a href="sqlite.configuration.php#ini.sqlite.assoc-case" class="link">sqlite.assoc_case</a> configuration
option.</p>
 </div>


 <a name="function.sqlite-fetch-all.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 Procedural example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dbhandle&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;email&nbsp;FROM&nbsp;users&nbsp;LIMIT&nbsp;25'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_fetch_all</span><span style="color: #007700">(</span><span style="color: #0000BB">$query</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQLITE_ASSOC</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Name:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">'&nbsp;&nbsp;E-mail:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">[</span><span style="color: #DD0000">'email'</span><span style="color: #007700">];<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
  <p class="para">
   </p><div class="example">
    <p><b>Example #2 Object-oriented example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dbhandle&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SQLiteDatabase</span><span style="color: #007700">(</span><span style="color: #DD0000">'sqlitedb'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;email&nbsp;FROM&nbsp;users&nbsp;LIMIT&nbsp;25'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;buffered&nbsp;result&nbsp;set<br /></span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$dbhandle</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">unbufferedQuery</span><span style="color: #007700">(</span><span style="color: #DD0000">'SELECT&nbsp;name,&nbsp;email&nbsp;FROM&nbsp;users&nbsp;LIMIT&nbsp;25'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;unbuffered&nbsp;result&nbsp;set<br /><br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$query</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetchAll</span><span style="color: #007700">(</span><span style="color: #0000BB">SQLITE_ASSOC</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Name:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">'&nbsp;&nbsp;E-mail:&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">[</span><span style="color: #DD0000">'email'</span><span style="color: #007700">];<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


 <a name="function.sqlite-fetch-all.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.sqlite-fetch-array.php" class="function" rel="rdfs-seeAlso">sqlite_fetch_array()</a> - Fetches the next row from a result set as an array</li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites