Posted inCodeigniter

How to get last executed query in PHP Codeigniter?

Today, We want to share with you last query in ci.In this post we will show you echo in controller codeigniter, hear for codeigniter print query before executing we will give you demo and example for implement.In this post, we will learn about How To Print Last Query In Codeigniter? with an example.

How to get last executed mysql query in Codeigniter

Printing the query executed last by codeigniter framework using active record class

How To Get Last Query In PHP Codeigniter?

public function member()
{
    $this->db->select('*'); 
    $query = $this->db->get("member");
    $str = $this->db->last_query();
    echo "
";
    print_r($str);
}

Output:

SELECT * FROM `member`

Last Query Function

  $this->db->last_query();

Get the last executed Query in Codeigniter

$lastquery = $this->db->last_query();
echo $lastquery;

This will print the query in the format

/// SELECT * FROM Shoppings....

I hope you get an idea about last query in ci.
I would like to have feedback on my infinityknow.com 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 Pakainfo.com. 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