Group By Method

Group By method is part of database class builder for selecting column data into a table.


Group By method has 1 required parameters that is column name and value, another parameters are optional. Here is the completed parameters can be used by where methods

$this->db->group_by(string $condition): dbObject


Condition can be single column name or can be SQL Function.

Example usage

Here is the examples using group_by method. See the first of this page for full example.

Basic Usage

For example we assumed want to add new data in blog table. First, in the model:

class Blog_Model extends SENE_Model{
  var $tbl = 'blog';
  var $tbl_as = 'b';
  public function __construct(){
  public function countByCategory(){
    return $this->db->get();

at the controller, we assumed has file named blog.php

class Blog extends Sene_Controller{
  public function __construct(){
    $this->load('blog_model','bm'); #class scope model
  public function index(){
    $blogs = $this->bm->countByCategory();