- Seme Framework
- Credits
- Version 3.2.X
- Issue
- Deployment
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
Parameters
This method has 2 required parameters.
$column_name
The $column_name value can be filled by column name or function string.
$sort_direction
The $sort_direction value can be string like:
asc
for ascending or,desc
for descending
Example
For example we assumed want to retrieve newest articles from blog table.
<?php
class Blog_Model extends SENE_Model{
var $tbl = 'blog';
var $tbl_as = 'b';
public function __construct(){
parent::__construct();
}
public function getLatest($di){
$this->db->order_by("create_date","desc");
return $this->db->get();
}
}