title: CodeIgniter, how to return multiple queries from model to controller?
body: <p>I'm trying to get my model to return two queries, one for the data itself which are multiple records from the table 'Categories', and a count field, from the table 'Posts'.</p>
  
  <p>I've tried alot of possible solutions, but so far none fixed it for me.</p>
  
  <p>My view does work with the correct route /forum/$id, but loading the categories and a post count per category won't work.</p>
  
  <p>Categories Controller:</p>
  
  <pre><code>$this-&gt;load-&gt;database();
  $this-&gt;load-&gt;model("Categories_model");
  
  $results=$this-&gt;Categories_model-&gt;getCategories();
  
  $data=array('results'=&gt;$results);
  
  $this-&gt;load-&gt;view('Categories_view',$results);
  </code></pre>
  
  <p>Categories Model:</p>
  
  <pre><code>// this works if I only want to get all the categories  
  // $query=$this-&gt;db-&gt;get('Categories');
  // return $query-&gt;result();
  
  $query1 = $this-&gt;db-&gt;get('Categories');
  $query2 = $this-&gt;db-&gt;query("SELECT COUNT(*) AS rowCount FROM Posts");
  
  $return array('categories' =&gt; $query1, 'count' =&gt; $query2);
  </code></pre>
  
  <p>Categories View:</p>
  
  <pre><code>&lt;tbody&gt;
      &lt;?php foreach ($results['categories'] as $r):?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;a href="&lt;?php echo site_url('forum'); ?&gt;/&lt;?=$r-&gt;CategorieId?&gt;"&gt;&lt;?=$r-&gt;Name?&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?=$r-&gt;rowCount?&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;?php endforeach;?&gt; 
  &lt;/tbody&gt;
  </code></pre>
  
  <p>When I load the Categories view, I get this error: </p>
  
  <blockquote>
    <p>syntax error, unexpected 'array' (T_ARRAY), Filename: models/Categories_model.php</p>
  </blockquote>
  
  <p>Can somebody help me with some sample code on how to do this, or a fix for my current code?</p>
  
  <p>Thank you in advance!</p>