Exec Method
Exec method is used executing the raw SQL agains the table.
Parameters
Query method has 1 required parameter.
$this->db->query(string $sql): boolean
$sql
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_order'; var $tbl_as = 'dor'; public function __construct(){ parent::__construct(); $this->db->from($this->tbl,$this->tbl_as); } public function massUpdateProduct($id){ $sql = 'UPDATE products SET is_published =0 WHERE DATE(date_created) < DATE("2019-01-01")'; return $this->db->exec($sql); } }