Codeigniter自动将字段添加到order_by

时间:2018-06-18 09:42:45

标签: codeigniter

我希望通过查询获得大多数视图:

        $this->db->select("a.pid, a.title, a.pic, a.date_created, d.view as post_view");
        $this->db->from("posts as a");
        $this->db->join('views as d', 'd.post_id=a.pid');  
        $this->db->join('cats as b', 'b.catid=a.catid'); //ensure Cat existed
        $this->db->where("a.block", 0);
        $this->db->order_by("d.view", "desc");
        $this->db->limit(5);
        $query = $this->db->get();
        return $query->result();

但始终自动添加order_by pid asc 。并且从不 d.view 字段订购desc。我尝试打印查询字符串,在这里:

SELECT `a`.`pid`, `a`.`title`, `a`.`pic`, `a`.`date_created`, `d`.`view` as `post_view` FROM `posts` as `a` JOIN `views` as `d` ON `d`.`post_id`=`a`.`pid` JOIN `cats` as `b` ON `b`.`catid`=`a`.`catid` WHERE `a`.`block` =0 ORDER BY `pid` asc, `d`.`view` DESC LIMIT 5

有任何修复建议吗? (CI版本3。*)

0 个答案:

没有答案