Showing posts with label Codeigniter. Show all posts
Showing posts with label Codeigniter. Show all posts

Thursday, 16 April 2020

How to get last executed query in Codeigniter?

Are you want to display last executed query in Codeigniter ?
You can use last_query() function of db class in Codeigniter.


You can use in controller and get output of last executed query:






Example : 


public function get_cities(){  

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


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

           echo "<pre>";

           print_r($str);

           exit;

}



Output:


SELECT * FROM `items`