Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php codeigniter中的子串查询_Php_Sql_Codeigniter - Fatal编程技术网

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将不会尝试使用反勾号保护字段或表名