To get Last inserted results from the MySQL table in Codeigniter use limit(). when you insert some values into the database and get this value at the same time, you need to use descending order to get the result. If you want to get results using descending order with the Limit so, try with this code:
<?php // -- Codeigniter Last id Select -- // $this->db->select('*'); $this->db->from('Table Name'); $this->db->order_by("id", "desc"); $this->db->limit(1); $query = $this->db->get();
Question and answer is powered by AnsPress.io