3 回答
TA贡献1852条经验 获得超7个赞
您可以使用 调用 select 方法FALSE as the last parameter
,如下所示
$this->db->select('A.city_id, A.`name` AS city_name, B.`name` AS state_name, C.`name` AS country_name, IF(`A.visible`,"Yes","No") AS active',false);
这将阻止 CI 在您的查询中添加 `
TA贡献1812条经验 获得超5个赞
尝试将您的查询更新为
$this->db->select('A.city_id, A.`name` AS city_name, B.`name` AS state_name, C.`name` AS country_name, IF(`A.visible`,"Yes","No") AS active',false);
$this->db->from('abs_city AS A');
$this->db->join('abs_state AS B', 'A.state_id = B.state_id AND B.visible = 1 AND A.country_id = B.country_id ', 'inner');
$this->db->join('abs_countries AS C', 'A.country_id = C.country_id AND B.visible = 1 ', 'inner' );
#$this->db->where('A.visible = 1');
return $this->db->get()->result();
TA贡献1828条经验 获得超3个赞
不要将false
参数添加到您的 SELECT 语句(这本质上是不安全的),而是尝试将语句更改为:
$this->db->select('A.city_id, A.`name` AS city_name, B.`name` AS state_name, C.`name` AS country_name, IF(A.visible,"Yes","No") AS active');
(只需删除周围的反引号A.visible
)
这是一个比添加FALSE
参数更安全的版本。后者将阻止查询生成器添加到已构建语句的自动转义,从而使整个 select 语句的安全性降低,这是不可取的
- 3 回答
- 0 关注
- 96 浏览
添加回答
举报