You can use $this->db->last_query(); to display the query string.
You can use print_r($query); to display the query result.

BY Best Interview Question ON 13 Jan 2019