title: Codeigniter return result and row
body: <p>In the Model class I use <code>return $query-&gt;row();</code> to return single rows and <code>return $query-&gt;result();</code> when returning multiple rows. </p>
  
  <p>On a single page I have to return single rows and multiple rows from 2 separate tables. </p>
  
  <p>Table <code>users</code> contains general information like the user name, full name, and email address.
  Table <code>user_links</code> contains links submitted by the respective user and has multiple rows for each user.</p>
  
  <p>My query</p>
  
  <pre><code>        $this-&gt;db-&gt;select('*');
          $this-&gt;db-&gt;from('users');
          $this-&gt;db-&gt;join('user_links', "user_links.user_id = users.user_id");
          $this-&gt;db-&gt;where('users.user_id', $user_id);
          $this-&gt;db-&gt;where('user_links.user_id', $user_id);
          $query = $this-&gt;db-&gt;get();
          return $query-&gt;row(); 
  </code></pre>
  
  <p>In my controller I load the query in my view by </p>
  
  <p><code>$data['row'] = $this-&gt;User_model-&gt;user_read($user_id);</code>, </p>
  
  <p><code>$user_id</code> being the 3rd URL segment containing the unique user id.  </p>
  
  <p>Finally, in my view I retrieve rows by <code>echo $row-&gt;first_name;</code></p>
  
  <p>This works for single rows but how can I create a <code>foreach</code> loop for user links? The goal is to avoid loops for single rows and use them just for retrieving multiple rows. </p>