- 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
- putThemeContent
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
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
Parameters
The esc method required only 1 parameter, it is $val.
$val
Can contain int
or string
to be escaped
.
Example
Here is the example for esc method on d_order_model.php
file.
<?php
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(){
parent::__construct();
$this->db->from($this->tbl,$this->tbl_as);
}
public function getByKode($kode){
$this->db->from($this->tbl,$this->tbl_as);
$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";