- Seme Framework
- version 4.0.3
- Requirements
- Download & Install
- Configuration
- Tutorials
- URI Routing
- Constants
- Global Variables
- Model
- View
- Controller
- cdn_url
- config
- constructor
- getAdditional
- getAdditionalBefore
- getAdditionalAfter
- getAuthor
- getCanonical
- getContentLanguage
- getDescription
- getIcon
- getJsContent
- getJsFooter
- getJsReady
- getKey
- getKeyword
- getLang
- getRobots
- getShortcutIcon
- getThemeElement
- getTitle
- input
- lib
- load
- loadCss
- loadLayout
- putThemeContent
- putJsContent
- putJsFooter
- putJsReady
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Group By Method
The group_by
method is part of Query Builder
method for grouping result set by running GROUP BY
SQL command.
Basic Usage
Here is the basic usage group_by
method from $db
property on SENE_Model class.
$this->db->group_by(string $expression): $this->db
Parameters
This method has 1 required one parameter.
$expression
The $expression value can be single column name or can be SQL Function that compatible with GROUP BY
command.
Example
Here is the source code implementation of group_by
method in a model class.
class Blog_Model extends \SENE_Model{
public $tbl = 'blog';
public $tbl_as = 'b';
public function __construct(){
parent::__construct();
}
public function countByCategory(){
$this->db->select_as("COUNT(*)",'total',0);
$this->db->select_as("category",'category',0);
$this->db->from($this->tbl,$this->tbl_as);
$this->db->group_by("category");
return $this->db->get();
}
}