I have a sql statement in my model,
I then say
$query = $this->db->query($sql, array(fields, fields1); if ($query) { return true: } else {
You can display the ActiveRecord generated SQL:
Before the query runs:
$this->db->_compile_select();
And after it has run:
$this->db->last_query();