Order By Method

The order_by method is part of database class builder for sorting result query.

Basic Usage

Here is the basic usage order_by method from $db property on SENE_Model class.

$this->db->group_by(string $column_name, string $sort_direction): $this->db


This method has 2 required parameters.


The $column_name value can be filled by column name or function string.


The $sort_direction value can be string like:

  • asc for ascending or,
  • desc for descending


For example we assumed want to retrieve newest articles from blog table.

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