Mein ModellErhalten Sie die aktuellsten Datensatz mit Limit in codeigniter
public function getLogs()
{
$this->db->limit(5);
$query = $this->db->get('tbllogs');
return $query->result();
}
Mein ModellErhalten Sie die aktuellsten Datensatz mit Limit in codeigniter
public function getLogs()
{
$this->db->limit(5);
$query = $this->db->get('tbllogs');
return $query->result();
}
Versuchen Sie, diese
$this->db->order_by("id", "desc");
$this->db->limit(5);
$query = $this->db->get('tbllogs');
return $query->result();
Oder old
und latest
Logik zwei Links in Ihrer Ansicht mit orderBy
Abfrageparametern in ihm machen.
<a href="/controller/method?orderBy='old'">Old</a>
<a href="/controller/method?orderBy='latest'">Latest</a>
In Ihrer Controller-Methode
if ($this->input->get('orderBy') == 'old') {
$this->db->order_by("id", "asc");
} else {
$this->db->order_by("id", "desc");
}
$this->db->limit(5);
$query = $this->db->get('tbllogs');
return $query->result();
Was ist das Problem? Was ist die Frage? – Tpojka
Zayn Ali bereits beantwortet – Holow