private function connectAndCreate($server, $type, $username, $password, $database)
    {
        $conn = ADONewConnection($this->isPDO($type) ? 'pdo' : $type);
        $conn->SetFetchMode(ADODB_FETCH_BOTH);
        $conn = $this->setConnectTimeout($conn, $type);
        $connected = $conn->Connect($this->getDSN($server,$type,false),$username,$password,$database);
        $conn = $this->clearConnectTimeout($conn, $type);
        if ($connected) {
            $this->last_connect_error = false;
            $adapter = $this->getAdapter(strtolower($type));
            $stillok = $conn->Execute($adapter->createNamedDB($database));
            if (!$stillok) {
                $this->last_connect_error = $conn->ErrorMsg();
                $this->connections[$database] = false;
                return false;
            }
            $conn->Execute($adapter->useNamedDB($database));
            $conn->SelectDB($database);
            $this->connections[$database] = $conn;
            return true;
        } else {
            $this->last_connect_error = $conn->ErrorMsg();
            $this->connections[$database] = false;
            return false;
        }
    }
private function connectAndCreate($server, $type, $username, $password, $database)
    {
        $conn = ADONewConnection($this->isPDO($type) ? 'pdo' : $type);
        $conn->SetFetchMode(ADODB_FETCH_BOTH);
        $conn = $this->setConnectTimeout($conn, $type);
        $connected = $conn->Connect($this->getDSN($server,$type,false),$username,$password,$database);
        $conn = $this->clearConnectTimeout($conn, $type);
        if ($connected) {
            $this->last_connect_error = false;
            $adapter = $this->getAdapter(strtolower($type));
            $stillok = $conn->Execute($adapter->createNamedDB($database));
            if (!$stillok) {
                $this->last_connect_error = $conn->ErrorMsg();
                $this->connections[$database] = false;
                return false;
            }
            $conn->Execute($adapter->useNamedDB($database));
            $conn->SelectDB($database);
            $this->connections[$database] = $conn;
            return true;
        } else {
            $this->last_connect_error = $conn->ErrorMsg();
            $this->connections[$database] = false;
            return false;
        }
    }
private function connectAndCreate ( $ server , $ type , $ username , $ password , $ database ) { $ conn = ADONewConnection ( $ this -> isPDO ( $ type ) ? 'pdo' : $ type ) ; $ conn -> SetFetchMode ( ADODB_FETCH_BOTH ) ; $ conn = $ this -> setConnectTimeout ( $ conn , $ type ) ; $ connected = $ conn -> Connect ( $ this -> getDSN ( $ server , $ type , false ) , $ username , $ password , $ database ) ; $ conn = $ this -> clearConnectTimeout ( $ conn , $ type ) ; if ( $ connected ) { $ this -> last_connect_error = false ; $ adapter = $ this -> getAdapter ( strtolower ( $ type ) ) ; $ stillok = $ conn -> Execute ( $ adapter -> createNamedDB ( $ database ) ) ; if ( ! $ stillok ) { $ this -> last_connect_error = $ conn -> ErrorMsg ( ) ; $ this -> connections [ $ database ] = false ; return false ; } $ conn -> Execute ( $ adapter -> useNamedDB ( $ database ) ) ; $ conn -> SelectDB ( $ database ) ; $ this -> connections [ $ database ] = $ conn ; return true ; } else { $ this -> last_connect_error = $ conn -> ErrorMsg ( ) ; $ this -> connections [ $ database ] = false ; return false ; } }
Try connecting without specifying a database
and then creating the requested database
Try connecting without specifying a database and then creating the requested database