title: What is best to use, fetch_array(MYSQLI_ASSOC) or fetch_all(MYSQLI_ASSOC)?
body: <p>They are two functions of mysqli_result.</p>
  
  <ul>
  <li>fetch_array(): Fetch a result row.</li>
  </ul>
  
  <p>In this way, query for each row to the database?</p>
  
  <ul>
  <li>fetch_all(): Fetches all result rows.</li>
  </ul>
  
  <p>And in this way, only query once to the database?</p>
  
  <p>I do not know how to do it in the best way and the most efficient way.</p>
  
  <p>Put examples:</p>
  
  <p>1.-fetch_array():</p>
  
  <pre><code>$resultUsers = getAllUsers($db);
  while($row = $resultUsers-&gt;fetch_array()){
       echo $row['name'];
  }
  </code></pre>
  
  <p>2.- fetch_all():</p>
  
  <pre><code>$resultUsers = getAllUsers($db);
  foreach ($resultUsers-&gt;fetch_all(MYSQLI_ASSOC) as $value) {
      echo $value['name'] . "&lt;br&gt;";
  }
  </code></pre>
  
  <p>2.A.-</p>
  
  <pre><code>foreach (getAllUser($db)-&gt;fetch_all(MYSQLI_ASSOC) as $value) {
      echo $value['name'] . "&lt;br&gt;";
  }
  </code></pre>
  
  <p>If there is a better way to do it, I hope your help.</p>