- Seme Framework
- Credits
- Version 3.2.X
- Issue
- Deployment
Exec Method
The exec
method is used for executing raw SQL against the table.
Basic Usage
Here is the basic usage exec
method from $db
property on SENE_Model class.
$this->db->exec(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 exec
method in a model class.
class C_Produk_Model extends SENE_Model {
var $tbl = 'c_produk';
var $tbl_as = 'cp';
public function __construct(){
parent::__construct();
$this->db->from($this->tbl,$this->tbl_as);
}
...
public function unpublishOldProduct($id){
$sql = 'UPDATE '.$this->tbl.' SET is_published = 0 WHERE DATE(date_created) < DATE("2019-01-01")';
return $this->db->exec($sql);
}
...
}