Php 如何使用codeigniter从表中获取最后3行?
我有一个从数据库加载注释的函数。 在另一页中, 我想从数据库中的表中获取最后3行(这样它就会显示最后3条注释)。 这就是我在模型中的功能:Php 如何使用codeigniter从表中获取最后3行?,php,database,codeigniter,get,Php,Database,Codeigniter,Get,我有一个从数据库加载注释的函数。 在另一页中, 我想从数据库中的表中获取最后3行(这样它就会显示最后3条注释)。 这就是我在模型中的功能: public function load3Comments(){ $this->db->order_by("c_id", "desc"); $query = $this->db->get('comment'); return $this->get_resul
public function load3Comments(){
$this->db->order_by("c_id", "desc");
$query = $this->db->get('comment');
return $this->get_results($query);
}
应该这样做。它在CI中有一个函数 更具描述性。这个函数的输出是什么?预期产量是多少?这本身并不能告诉我们很多。
public function load3Comments(){
$this->db->order_by("c_id", "desc");
$this->db->limit(3);
$query = $this->db->get('comment');
return $this->get_results($query);
}