Printing a last executed SQL query in Codeigniter is pretty simple. Usually in the development phase we all will debug the database result by printing the query to see whether the SQL is returning any value or not. In Codeigniter framework we can print the last executed SQL query in single line. You can add this line to common Codeigniter library function and when ever you want to print the SQL you can call back the function.
The above script will work like similar to “mysql_insert_id();” . Yes Codeigniter will print the last executed SQL string.
- Helps in debugging
- Check DB result sets