Php codeigniter中的子串查询
我想要一个写以下查询Php codeigniter中的子串查询,php,sql,codeigniter,Php,Sql,Codeigniter,我想要一个写以下查询 SELECT SUBSTRING(zsmonth, 5, 2) as month FROM (`tblsales_month`) 所以我写了下面的代码 $this->db->select('SUBSTRING(zsmonth, 5, 2) as month') ->from('tblsales_month'); 但它会生成带有不必要的反报价的以下查询 SELECT SUBSTRING(zsmonth, `5`, `2)` as mon
SELECT SUBSTRING(zsmonth, 5, 2) as month FROM (`tblsales_month`)
所以我写了下面的代码
$this->db->select('SUBSTRING(zsmonth, 5, 2) as month')
->from('tblsales_month');
但它会生成带有不必要的反报价的以下查询
SELECT SUBSTRING(zsmonth, `5`, `2)` as month FROM (`tblsales_month`)
最好的方法是什么 添加第二个参数
FALSE
,如:
$this->db->select('SUBSTRING(zsmonth, 5, 2) as month', FALSE)
->from('tblsales_month');
将第二个参数设置为FALSE
,CodeIgniter将不会尝试使用反勾号保护字段或表名