public function __destruct() { // static elements are deleted automatically at the end of the PHP script, // so there is no need to destroy this singleton explicitly if (!is_null(self::$instance)) { $this->close(); // close the database connection self::$instance = null; } }