title: Using $this->db->get()->row_array() in Codeigniter
body: <p>I'm using <code>$this-&gt;db-&gt;get()-&gt;row_array()</code> in Codeigniter to get a single row of results from the database. I want to merge the results from all the different queries into a single array <code>$results</code>; So I dont want to have to type in the column name to get the result of a single row... </p>
  
  <p><strong>PHP Code</strong></p>
  
  <pre><code>// Query 1
  $results = array();
  $this-&gt;db-&gt;select('COUNT(listing_id) as num')
          -&gt;from('listings')
          -&gt;where('city', $city);
  $result = $this-&gt;db-&gt;get()-&gt;row_array();
  $results['num'] = $result['num'];
  </code></pre>
  
  <p>These 2 lines below appear to me that there can be a shorter way to write this. Is there? THanks!</p>
  
  <pre><code>$result = $this-&gt;db-&gt;get()-&gt;row_array();
  $results['num'] = $result['num'];
  </code></pre>
  
  <p><strong>Desired solution</strong></p>
  
  <p><code>$results['num'] = first_element_of($this-&gt;db-&gt;get()-&gt;row_array());</code> will be great!</p>