<!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>Fetches all result rows as an associative array, a numeric array, or both</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqli-result.data-seek.html">mysqli_result::data_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqli-result.fetch-array.html">mysqli_result::fetch_array</a></div> <div class="up"><a href="class.mysqli-result.html">mysqli_result</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mysqli-result.fetch-all" class="refentry"> <div class="refnamediv"> <h1 class="refname">mysqli_result::fetch_all</h1> <h1 class="refname">mysqli_fetch_all</h1> <p class="verinfo">(PHP 5 >= 5.3.0)</p><p class="refpurpose"><span class="refname">mysqli_result::fetch_all</span> -- <span class="refname">mysqli_fetch_all</span> — <span class="dc-title">Fetches all result rows as an associative array, a numeric array, or both</span></p> </div> <div class="refsect1 description" id="refsect1-mysqli-result.fetch-all-description"> <h3 class="title">Description</h3> <p class="para">Object oriented style</p> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>mysqli_result::fetch_all</strong></span> ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$resulttype</code><span class="initializer"> = MYSQLI_NUM</span></span> ] )</div> <p class="para rdfs-comment">Procedural style</p> <div class="methodsynopsis dc-description"> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>mysqli_fetch_all</strong></span> ( <span class="methodparam"><span class="type"><a href="class.mysqli-result.html" class="type mysqli_result">mysqli_result</a></span> <code class="parameter">$result</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$resulttype</code><span class="initializer"> = MYSQLI_NUM</span></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>mysqli_fetch_all()</strong></span> fetches all result rows and returns the result set as an associative array, a numeric array, or both. </p> </div> <div class="refsect1 parameters" id="refsect1-mysqli-result.fetch-all-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter"> result</code></em></span><dd> <p class="para">Procedural style only: A result set identifier returned by <span class="function"><a href="mysqli.query.html" class="function">mysqli_query()</a></span>, <span class="function"><a href="mysqli.store-result.html" class="function">mysqli_store_result()</a></span> or <span class="function"><a href="mysqli.use-result.html" class="function">mysqli_use_result()</a></span>.</p></dd> </dt> <dt> <span class="term"><em><code class="parameter">resulttype</code></em></span> <dd> <p class="para"> This optional parameter is a constant indicating what type of array should be produced from the current row data. The possible values for this parameter are the constants <strong><code>MYSQLI_ASSOC</code></strong>, <strong><code>MYSQLI_NUM</code></strong>, or <strong><code>MYSQLI_BOTH</code></strong>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-mysqli-result.fetch-all-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an array of associative or numeric arrays holding result rows. </p> </div> <div class="refsect1 mysqlnd" id="refsect1-mysqli-result.fetch-all-mysqlnd"> <h3 class="title">MySQL Native Driver Only</h3> <p class="para"> Available only with <a href="book.mysqlnd.html" class="link">mysqlnd</a>. </p> <p class="para"> As <span class="function"><strong>mysqli_fetch_all()</strong></span> returns all the rows as an array in a single step, it may consume more memory than some similar functions such as <span class="function"><a href="mysqli-result.fetch-array.html" class="function">mysqli_fetch_array()</a></span>, which only returns one row at a time from the result set. Further, if you need to iterate over the result set, you will need a looping construct that will further impact performance. For these reasons <span class="function"><strong>mysqli_fetch_all()</strong></span> should only be used in those situations where the fetched result set will be sent to another layer for processing. </p> </div> <div class="refsect1 seealso" id="refsect1-mysqli-result.fetch-all-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="mysqli-result.fetch-array.html" class="function" rel="rdfs-seeAlso">mysqli_fetch_array()</a> - Fetch a result row as an associative, a numeric array, or both</span></li> <li class="member"> <span class="function"><a href="mysqli.query.html" class="function" rel="rdfs-seeAlso">mysqli_query()</a> - Performs a query on the database</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="mysqli-result.data-seek.html">mysqli_result::data_seek</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqli-result.fetch-array.html">mysqli_result::fetch_array</a></div> <div class="up"><a href="class.mysqli-result.html">mysqli_result</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>