Jump to content

prestashop stops when connection to external database is not successful


Recommended Posts

hello there! I have this hook where it connects to a database. When the connection is successful it works fine. But when the connection fails it does not let me enter the main page. How can I make prestashop continue even if there is an error in the connection to the database?

public function hookHeader() {
        $this->context->controller->addJS($this->_path . '/views/js/front.js');
        $this->context->controller->addCSS($this->_path . '/views/css/front.css');
        
        $database = Configuration::get('MIMODULOMISMADB_ACCOUNT_NOMBREDB', null);
        $user = Configuration::get('MIMODULOMISMADB_ACCOUNT_USUARIO', null);
        $password = Configuration::get('MIMODULOMISMADB_ACCOUNT_PASSWORD', null);
        try {
            $db = new DbMySQLi("localhost", $user, $password, $database, true);
        } catch (PrestaShopWebserviceException $ex) {
            mail("[email protected]", "conexion fallida", "hola");
            echo 'Other error : <br />' . $ex->getMessage();
        }
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...