ares333 发表于 2010-7-19 14:35:47

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();

sunjava 发表于 2013-2-12 18:03:39

感谢分享。。。我终于找到用法了。。。呵呵。
页: [1]
查看完整版本: CI ar distinct 的正确用法