Posted inCodeigniter

ci last query | last query ci | get last query codeigniter Example

Today, We want to share with you ci last query.In this post we will show you codeigniter last insert id, hear for Print last query we will give you demo and example for implement.In this post, we will learn about Insert Query In Codeigniter Example Tutorial with an example.

How to get last executed mysql query in Codeigniter ?

codeigniter last query
codeigniter last query

you can place it in the controller or model (even the view if you wish


Returns the last query that was run (the query string, not the result). Example:
$str = $this->db->last_query();
echo $str;

// Produces: SELECT * FROM products....

Example 1:

echo '
echo '


last query executed in MySQL by using Codeigniter 3

Example 2:
last_query() function is the inbuilt function of codeigniter 3.

public function check_query(){
    $query = $this->db->get("shops");
    $results = $this->db->last_query();
    echo $results;


select * from shops.

I hope you get an idea about echo last query in php.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype