title: codeigniter group_by returning only first row
body: <p>i have this problem in codeigniter:
  I try to make a navigation tree system from database.</p>
  
  <p>model: </p>
  
  <pre><code>function getServices()
  {
   $this-&gt;db-&gt;select('service_url, service_title, category_title');    
   $this-&gt;db-&gt;join('services_category', 'services_category.id=services.category_id');    
   $this-&gt;db-&gt;group_by('category_title');
   $this-&gt;db-&gt;order_by('service_title', 'ASC');    
   $query = $this-&gt;db-&gt;get('services');
  
   if($query-&gt;result() == TRUE)    
   {    
      foreach($query-&gt;result_array() as $row)
      {
         $result[] = $row;
      }
      return $result;
    }
  }
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;?php if(isset($services) &amp;&amp; $services) : foreach($services as $s) : ?&gt;    
     &lt;ul&gt;
       &lt;li&gt;&lt;a href="#"&gt;&lt;?php echo $s['category_title'] ?&gt;&lt;/a&gt;    
         &lt;ul&gt;
          &lt;li&gt;&lt;?php echo anchor('services/' . $s['service_url'], $s['service_title']); ?&gt;&lt;/li&gt;
         &lt;/ul&gt;    
       &lt;/li&gt;    
     &lt;/ul&gt;    
  &lt;?php endforeach; ?&gt;    
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>now so far so good, the result is returning each category the way is supposed to, but the service is returning only one service per category, and in some categories there is like 15 services.
  Anybody kind to give me a hand, or an explanation what is going wrong ?
  Thank you so much.</p>
  
  <p>"i'm not an expert in php or codeigniter, i just started not long time ago, so please don't shoot the beginner."</p>
  
  <p>note: i tried without the group_by and order_by, and is returning all services, but the categories are repeating,</p>
  
  <p>ex:</p>
  
  <pre><code>category-a
     service1
  category-a
     service2
  category-b
     service10
  category-b
     service11
  category-c
     service30
  category-c
    service31
  ....
  </code></pre>