Getting CodeIgniter Active Record's current SQL code
You can also use $this->db->get_compiled_select()
. The difference between get_compiled_select()
and last_query()
is that get_compiled_select()
gives the query string generated even if you don't run the query against the database.
Try
echo $this->db->last_query();
after you run your Active Record Query and it'll spit out the raw SQL it ran for you. I use it often.