PMA\libraries\DatabaseInterface::connect PHP Method

connect() public method

connects to the database server
public connect ( integer $mode, array $server = null ) : mixed
$mode integer Connection mode on of CONNECT_USER, CONNECT_CONTROL or CONNECT_AUXILIARY.
$server array Server information like host/port/socket/persistent
return mixed false on error or a connection object on success
    public function connect($mode, $server = null)
    {
        list($user, $password, $server) = $this->getConnectionParams($mode, $server);
        if (is_null($user) || is_null($password)) {
            trigger_error(__('Missing connection parameters!'), E_USER_WARNING);
            return false;
        }
        // Do not show location and backtrace for connection errors
        $GLOBALS['error_handler']->setHideLocation(true);
        $result = $this->_extension->connect($user, $password, $server);
        $GLOBALS['error_handler']->setHideLocation(false);
        if ($result) {
            /* Run post connect for user connections */
            if ($mode == DatabaseInterface::CONNECT_USER) {
                $this->postConnect($result);
            }
            return $result;
        }
        if ($mode == DatabaseInterface::CONNECT_CONTROL) {
            trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING);
            return false;
        } else {
            if ($mode == DatabaseInterface::CONNECT_AUXILIARY) {
                // Do not go back to main login if connection failed
                // (currently used only in unit testing)
                return false;
            }
        }
        Logging::logUser($user, 'mysql-denied');
        $GLOBALS['auth_plugin']->authFails();
        return $result;
    }