Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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->db->connect();
    $this->view->setVar('db_connect', 1);
    //Execute sql backup base database
} catch (\Exception $e) {
    $this->view->setVar('db_connect', 0);
    //Display view config
}


1.2k
Accepted
answer

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