title: Get associative array of each row in CodeIgniter ActiveRecord result
body: <p>In CodeIgniter there is a function <code>query-&gt;row_array</code> which will give you an associative array of your result, mapping column names to values. However this function only works if there is a single row as a result.</p>
  
  <p>What I need is a function which will return an associative array for each row in the query result.</p>
  
  <p>I am currently doing:</p>
  
  <pre><code>$arr = array ();
  foreach ($query-&gt;result() as $row) {
    array_push ($arr, array("col1" =&gt; $row-&gt;col1, "col2" =&gt; $row-&gt;col2, ...));
  }
  return $arr;
  </code></pre>
  
  <p>Not only is this annoying to read and write, but it also doesn't scale as I add more columns to this table. I have similar code in several places, and I wish I could replace it with something that is cleaner.</p>
  
  <p>I was hoping for something like:</p>
  
  <pre><code>$arr = array ();
  foreach ($query-&gt;result() as $row) {
    array_push ($arr, $row-&gt;to_array());
  }
  return $arr;
  </code></pre>
  
  <p>Is there something like that? Or even better:</p>
  
  <pre><code>return $query-&gt;result_array ();
  </code></pre>