add checks in core\db\mysql destructor for is the db instance is both set and a resource before closing it.