Tag Archives: codeigniter print last executed query
Codeigniter print last query
Codeigniter print last query : Codeigniter provides database class to deal with database. You can use $this->db->last_query(); to print last executed query. This prints the last executed query by codeigniter. Here in this article we are going to create one example to print last query.
Codeigniter print last query | Syntax | Example
Syntax to print last query is given below-
$this->db->last_query();
Example – To print executed query at last In Codeigniter
$query = $this->db->get("users"); echo $this->db->last_query();
In the above example we have used get method to pull the data from users table. After execution it Will print the query – “Select * from users”. So on the same way you can print any complex query Like – Insert, Update, Delete, Joins, Union etc in Codeigniter.