for example, i want to convert this;
$this->db->get('table');
to this;
'SELECT * FROM table'
is there any function for this? i searched on the user guide of CI but didnt find any solution.
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.
Answer:
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.
Tags: codeigniter, phpphp, sql