In this tutorial, I will inform you how to get the last record from the MySQL table in CodeIgniter. we need sometimes the last record in MySQL using CodeIgniter. Codeigniter’s provide Active record library, its library used to get the last record in MySQL and see below example.
if you want to get last record from database In case you used of CodeIgniter function order_by, limit, get and row. it functions help to get a single row of the result.
See below the example of getting the last record from MySQL using CodeIgniter.
public function add()
$last_record = $this->db->order_by('id',"desc")