Query Method

Query method is used to query the raw SQL.


Query method has 1 required parameter.

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


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_blog';
  var $tbl_as = 'dbl';
  public function __construct(){
  public function getLatePublish($id){
    $sql = 'SELECT `title`, `pubdt` AS 'datePublished'
    FROM '.$this->tbl.' '.$this->tbl_as.'
    WHERE is_published = 1
    ORDER BY cdate DESC
    LIMIT 0,1;';
    return $this->db->query($sql);