Query Method

Query method is used to query the raw SQL.

Parameters

Query method has 1 required parameter.

$this->db->query(string $sql): arrayOfObject

$sql

SQL can be single command of SQL.

Example usage

Here is the examples using SQL 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 = 'd_order';
	var $tbl_as = 'dor';
	public function __construct(){
		parent::__construct();
		$this->db->from($this->tbl,$this->tbl_as);
	}
	public function getReported($id){
    $sql = 'SELECT bk.name AS category FROM blog WHERE is_published = 1 ORDER BY created_date DESC LIMIT 0,1;';
		return $this->db->query($sql);
	}
}