Php 在codeigniter中获取具有限制的最新记录

Php 在codeigniter中获取具有限制的最新记录,php,codeigniter,model-view-controller,Php,Codeigniter,Model View Controller,我的型号 public function getLogs() { $this->db->limit(5); $query = $this->db->get('tbllogs'); return $query->result(); } 试试这个 $this->db->order_by("id", "desc"); $this->db->limit(5); $query = $this->db->get('

我的型号

public function getLogs()
{
    $this->db->limit(5);
    $query = $this->db->get('tbllogs');

    return $query->result();
}
试试这个

$this->db->order_by("id", "desc");
$this->db->limit(5);
$query = $this->db->get('tbllogs');

return $query->result();
或者对于
old
latest
逻辑,在视图中创建两个链接,其中包含
orderBy
查询参数

<a href="/controller/method?orderBy='old'">Old</a>
<a href="/controller/method?orderBy='latest'">Latest</a>
试试这个

$this->db->order_by("id", "desc");
$this->db->limit(5);
$query = $this->db->get('tbllogs');

return $query->result();
或者对于
old
latest
逻辑,在视图中创建两个链接,其中包含
orderBy
查询参数

<a href="/controller/method?orderBy='old'">Old</a>
<a href="/controller/method?orderBy='latest'">Latest</a>
有何条件

$result = $this->db->order_by('id', 'DESC')->limit(5)->get_where($tablename,$where);
有何条件

$result = $this->db->order_by('id', 'DESC')->limit(5)->get_where($tablename,$where);

问题是什么?问题是什么?Zayn Ali已经回答了问题是什么?问题是什么?Zayn Ali已经回答了任何建议?如果我把一些按钮放在我的视图上,当它点击时,最古老的日志会显示出来呢?谢谢,它帮了我很多忙!我很高兴这有帮助:)有什么建议吗?如果我把一些按钮放在我的视图上,当它点击时,最古老的日志会显示出来呢?谢谢,它帮了我很多忙!我很高兴这有帮助:)