I applied all the possible answers but still same problem. also tried
$this->db->reconnect();
there is no problem in my query
Just use this one if you use multiple query make in same function: $this->db->close();