CI ar distinct 的正确用法
刚才使用ar查询数据库发现distinct根本不起作用$this->db->distinct('citycode');
$this->db->from('area');
$this->db->get();
结果 SELECT DISTINCT * FROM (`area`);这毫无意义,试了n种方法不行,查看源码发现distinct不支持字段名作为参数.
正确的用法是用$this->db->select('citycode');确定字段名
$this->db->select('citycode');
$this->db->distinct();
$this->db->from('area');
$this->db->get(); 感谢分享。。。我终于找到用法了。。。呵呵。
页:
[1]