Mysql 如何在CodeIgniter中编写以下查询?
我正在CodeIgniter中开发一个应用程序,但我无法使用活动记录编写以下查询Mysql 如何在CodeIgniter中编写以下查询?,mysql,sql,codeigniter,codeigniter-3,Mysql,Sql,Codeigniter,Codeigniter 3,我正在CodeIgniter中开发一个应用程序,但我无法使用活动记录编写以下查询 select price, count(*) from fake_apps where downloads > 20000 group by price; 如何使用CodeIgniter的活动记录编写此查询 谢谢。情况如下: $this->db->select("price,count(*)",FALSE); $this->db->from("fake_apps"); $this-&
select price, count(*) from fake_apps where downloads > 20000 group by price;
如何使用CodeIgniter的活动记录编写此查询
谢谢。情况如下:
$this->db->select("price,count(*)",FALSE);
$this->db->from("fake_apps");
$this->db->where("downdoad>","20000");
$this->db->group_by("price);
$res = $this->db->get();
$this->db->select("price, count(*)",FALSE);
$this->db->where("downdoad > ","20000");
$this->db->group_by("price");
$sql = $this->db->get("fake_apps");
echo '<pre>';
print_r($this->db->last_query());
echo '</pre>';
注:
若您将其设置为FALSE,CodeIgniter将不会尝试保护您的字段
或带有反勾号的表名。如果需要化合物,这很有用
select语句
参考:
count(*)
周围加引号,但是count(*)
不是表的字段如果我们在选择中不使用FALSE,它会影响查询吗?
$this->db->select("price, count(*)",FALSE);