title: PHP - Get array of objects from query result
body: <p>Simplified version of the problem:</p>
  
  <p>So I have this query which is inside a function.</p>
  
  <pre><code>$query = "SELECT * FROM users";
  $result = mysql_query($query);
  </code></pre>
  
  <p>How I want to use mysql_fetch_object() to get an object from a row.</p>
  
  <p>Because in the end I wanted to get an array of objects I do this:</p>
  
  <pre><code>while ($a[] = mysql_fetch_object($result)) { // empty here }
  </code></pre>
  
  <p>In the end the function just returns $a. And it works almost fine.</p>
  
  <p>My problem is that mysql_fetch_object will return at the end a NULL "row" (which is normal because the result ended but I still assigned it to the array).</p>
  
  <p>Any ideas on how to do this in a decent way? Thanks in advance.</p>