I have a sql statement in my model,
I then say
$query = $this->db->query($sql, array(fields, fields1); if ($query) { return true: } else {
Neither last_query() or get_compiled_select() works for me, so a slight change of pedro's code works for me just fine. Do not include ->get() in your build, this must be before the ->get()
last_query()
get_compiled_select()
->get()
echo $this->EE->db->_compile_select();