如何使用codeigniter从表中获取最后3行


how do i get the 3 last rows from a table using codeigniter?

我有一个从数据库加载注释的函数。在另一页面中,我想从数据库中的表中获取最后3行(这样它就会显示最后3条注释)。这就是我的模型中的功能:

public function load3Comments(){
            $this->db->order_by("c_id", "desc");
            $query = $this->db->get('comment');
            return $this->get_results($query);
        }
public function load3Comments(){
            $this->db->order_by("c_id", "desc");
            $this->db->limit(3);
            $query = $this->db->get('comment');
            return $this->get_results($query);
        }

这就应该了。CI中有一个函数。http://ellislab.com/codeigniter/user-guide/database/active_record.html