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 simply use this at the end..
echo $this->db->last_query();