Esc Method

The esc method is used to process escape character while value passed Query Builder and will execute the PHP MySQLi command::real_escape_string .

Basic Usage

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

$this->db->esc(mixed $val): mixed


The esc method required only 1 parameter, it is $val.


Can contain int or string to be escaped.


Here is the example for esc method on d_order_model.php file.

class D_Order_Model extends SENE_Model{
  var $tbl = 'd_order';
  var $tbl_as = 'dor';
  var $tbl2 = 'd_order_detail';
  var $tbl2_as = 'dod';

  public function __construct(){
  public function getByKode($kode){
    $this->db->join($this->tbl2, $this->tbl2_as, 'id', $this->tbl_as, 'd_order_id', '');
    $this->db->where_as("$this->tbl_as.kode", $this->db->esc($kode));
    return $this->db->get();

SQL Result

The following is the SQL command that generated from D_Order_Model class methods.

-- result from executing D_Order_Model::getByKode('KN210803001') --
SELECT * FROM `d_order` WHERE `kode` = "KN210803001";