We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to check database connection success with Phalcon?

Hi, I want check database connection in Install website script. I use this code in InstallController But this is slowly. Do you have another solution?

//I use this code in InstallController
try {
    $this->view->setVar('db_connect', 1);
    //Execute sql backup base database
} catch (\Exception $e) {
    $this->view->setVar('db_connect', 0);
    //Display view config


Because $config->host is empty => time response slowly. Now I set default is 'localhost' :)