How to get last executed query in PHP Codeigniter?

How to get last executed query in PHP Codeigniter?

In this post we will give you information about How to get last executed query in PHP Codeigniter?. Hear we will give you detail about How to get last executed query in PHP Codeigniter?And how to use it also give you demo for it if it is necessary.

Are you wanted to get last executed sql query in codeigniter 3 project then i will help to get last query in codeigniter. We can get last executed query using last_query() function of db class in codeigniter.

It is a very simple to use $this->db->last_query() function to see SQL statements of last executed query in php codeigniter app. You have to simple code that function after your main query that you wanted check.

Here is a simple controller code and also output for last query:

Example:

public function test_db()

{

$query = $this->db->get("items");

$str = $this->db->last_query();

echo "<pre>";

print_r($str);

exit;

}

Output:

Also see:Codeigniter 3 create zip file and download example

SELECT *

FROM 'items'

I hope it can help you…

Hope this code and post will helped you for implement How to get last executed query in PHP Codeigniter?. 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 *

35  +    =  40

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