title: How to query the result of another query in Codeigniter
body: <p>I have a small problem:
  i created a function with a query that joined multiple tables and the function returns the query result.
  My question is: How can i query the result of that function? 
  None of the solutions searched here worked for me so far.
  Here's the code:</p>
  
  <pre><code>public  function manytomany(){
  $this-&gt;db-&gt;select(*)
          -&gt;from('tbl_users')
          -&gt;join('tbl_users_cars','tbl_users.user_id = tbl_users_cars.user_id')
          -&gt;join('tbl_cars','tbl_users_cars.car_id = tbl_cars.id')
          -&gt;join('tbl_car_model','tbl_cars.car_model_id = tbl_car_model.car_model_id')
          -&gt;order_by("user_id", "asc")
          -&gt;group_by("user_id");
  return $query = $this-&gt;db-&gt;get()-&gt;result();
  </code></pre>
  
  <p>How can i query the result in the same function? but outside the function?
  Thanks!</p>