How to get last record from the mysql table in codeigniter – onlinecode

How to get last record from the mysql table in codeigniter – onlinecode

In this post we will give you information about How to get last record from the mysql table in codeigniter – onlinecode. Hear we will give you detail about How to get last record from the mysql table in codeigniter – onlinecodeAnd how to use it also give you demo for it if it is necessary.

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()
{
    $this->load->database();
	$last_record = $this->db->order_by('id',"desc")
				->limit(1)
				->get('users')
				->row();
	echo "<pre>";			
	print_r($last_record);
	echo "</pre>";
	die;
}

Please follow and like us:

Hope this code and post will helped you for implement How to get last record from the mysql table in codeigniter – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

2  +    =  10

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US