Codeigniter how to display the query that was executed?
Filed Under (Others) by admin on 23-01-2012
To display the executed query using the codeigniter database class
insert the line of code below
echo $this->db->last_query();
$this->db->last_query(); //returns the last executed query
————————————————————————————————-
So if your code is like this
$this->db->select('*');
$this->db->from('sales');
$query = $this->db->get();
echo $this->db->last_query();
// Adding echo $this->db->last_query(); will output the query on the page like this
// SELECT * FROM sales;


