substring query in codeigniter
11,123
add second parameter FALSE
, like:
$this->db->select('SUBSTRING(zsmonth, 5, 2) as month', FALSE)
->from('tblsales_month');
Setting second parameter to FALSE
, CodeIgniter will not try to protect your field or table names with backticks.
Related videos on Youtube
Author by
Dinuka Thilanga
I was software engineer at eMarketingeye. Now i am Senior Software engineer at eFutures.
Updated on September 25, 2022Comments
-
Dinuka Thilanga about 1 year
I want a write following query.
SELECT SUBSTRING(zsmonth, 5, 2) as month FROM (`tblsales_month`)
So i wrote following code.
$this->db->select('SUBSTRING(zsmonth, 5, 2) as month') ->from('tblsales_month');
But it generate following query with unnecessary back quote.
SELECT SUBSTRING(zsmonth, `5`, `2)` as month FROM (`tblsales_month`)
What is the best way to do that?