Show SQL statement from CodeIgniter DB Query Builder

If you need to see (for whatever reason) the SQL being generated by CodeIgniter’s DB Query Builder, you can call last_query() on the helper

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

If you are using version 3 however, you should be able to use get_compiled_select() as mentioned in the CodeIgniter documentation

Add comment