- 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
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->order_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{
public $tbl = 'blog';
public $tbl_as = 'b';
public function __construct(){
parent::__construct();
}
public function getLatest($di){
$this->db->order_by("create_date","desc");
return $this->db->get();
}
}