Query Method

The query method is used for getting the result from a completed SQL command.

Basic Usage

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

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

Parameters

This method has 1 required parameter.

$sql

The $sql value can be a completed single command of SQL.

Example

Here is the example for query method in a model class.

<?php
class Blog_Model extends SENE_Model{
  var $tbl = 'd_blog';
  var $tbl_as = 'dbl';
  public function __construct(){
    parent::__construct();
    $this->db->from($this->tbl,$this->tbl_as);
  }
  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);
  }
}