PHP Codeigniter get last executed query example

PHP Codeigniter get last executed query example

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

In this post, i would like to show you how to get last executed query in php codeigniter 3 website using last_query() function. you can print last executed sql query like select query, create query, update query, delete query etc.

Whenever you are working on big amount of project and you write long query code using sub query, order by, group by etc. but we write sql query using codeigniter query builder so it might be easy for us. But if you need to print last executed query then you can do it using last_query() function.

Here, i will show you very simple example, so you can get it quickly. We will get all items from database table using select query as bellow example.

Controller Code:

/**

* Get All Data from this method.

*

* @return Response

*/

public function index()

{

$data['data'] = $this->db->get("items")->result();

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

print_r($executedQuery);

exit;

}

Output:

Also see:Stripe Payment Gateway Integration in Codeigniter Example

SELECT * FROM 'items'

I hope it can help you…

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

4  +  6  =  

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