title: CodeIgniter: Returning data as an object vs array
body: <p>There are functions to return your data as either an object:</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query("YOUR QUERY");
  
  if ($query-&gt;num_rows() &gt; 0)
  {
     foreach ($query-&gt;result() as $row)
     {
        echo $row-&gt;title;
        echo $row-&gt;name;
        echo $row-&gt;body;
     }
  }
  </code></pre>
  
  <p>Or an array:</p>
  
  <pre><code>$query = $this-&gt;db-&gt;query("YOUR QUERY");
  
  foreach ($query-&gt;result_array() as $row)
  {
     echo $row['title'];
     echo $row['name'];
     echo $row['body'];
  }
  </code></pre>
  
  <p>I've always returned my data as arrays, but when is a case that returning an "object" is preferable?</p>