Fixing scope of $this->db