How To Get Last Query In PHP Codeigniter?
Are you wanted to get last executed SQL query in Codeigniter, then i will help to get last query in Codeigniter. we can get last query to using last_query() function in Codeigniter.
It is a very simple to use $this->db->last_query() function to see SQL statements of last executed query in codeigniter Project. We have a simple code that functions after the main query that you wanted to check.
Here is a simple controller code and also output for last query:
Example:
public function product() { $this->db->select('*'); $query = $this->db->get("product"); $str = $this->db->last_query(); echo "<pre>"; print_r($str); }
Output:
SELECT * FROM `product`
I hope it can help you...
Leave a Reply