参考:http://codeigniter.com/forums/viewthread/96428/ Before the query runs: $this->db->_compile_select(); And after it has run: $this->db->last_query();