src/Controllers/AppController.php
protected function checkDatabaseInformation()
    {
        $this->title("Database Information");

        $errors = [];
        $driver = Request::$post->get('driver');

        // Check fields
        if ($driver == "pdo_pgsql" || $driver == "pdo_mysql") {
            if (!Request::$post->get('host')) {
                $errors[] = "Server is required";
            }

            if (!Request::$post->get('user')) {
                $errors[] = "Username is required";
            }

            if (!Request::$post->get('dbname')) {
                $errors[] = "Database name is required";
            }
        } elseif ($driver == "pdo_sqlite") {
            if (!Request::$post->get('path')) {
                $errors[] = "Database path is required";
            }
        }

        // Check connection
        if (!count($errors)) {
            $info = [
                'driver' => $driver,
            ];

            switch ($driver) {
                case "pdo_pgsql":
                case "pdo_mysql":
                    $info = $info + [
                        'host'     => Request::$post->get('host'),
                        'user'     => Request::$post->get('user'),
                        'password' => Request::$post->get('password'),
                        'dbname'   => Request::$post->get('dbname')
                    ];
                    break;

                case "pdo_sqlite":
                    $info['path'] = Request::$post->get('path');
                    break;
            }

            try {
                // Lets try to do a few things with the database to confirm a connection.
                $db = ConnectionManager::create($info);
                $sm = $db->getSchemaManager();
                $sm->listTables();
            } catch (DBALException $e) {
                $errors[] = "Unable to connect to database: " . $e->getMessage();
            }
        }

        if (count($errors)) {
            $this->title("Database Information");
            return $this->render("steps/database_information.phtml", [
                'errors' => $errors
            ]);
        }

        $_SESSION['db'] = $info;
    }
protected function checkDatabaseInformation()
    {
        $this->title("Database Information");

        $errors = [];
        $driver = Request::$post->get('driver');

        // Check fields
        if ($driver == "pdo_pgsql" || $driver == "pdo_mysql") {
            if (!Request::$post->get('host')) {
                $errors[] = "Server is required";
            }

            if (!Request::$post->get('user')) {
                $errors[] = "Username is required";
            }

            if (!Request::$post->get('dbname')) {
                $errors[] = "Database name is required";
            }
        } elseif ($driver == "pdo_sqlite") {
            if (!Request::$post->get('path')) {
                $errors[] = "Database path is required";
            }
        }

        // Check connection
        if (!count($errors)) {
            $info = [
                'driver' => $driver,
            ];

            switch ($driver) {
                case "pdo_pgsql":
                case "pdo_mysql":
                    $info = $info + [
                        'host'     => Request::$post->get('host'),
                        'user'     => Request::$post->get('user'),
                        'password' => Request::$post->get('password'),
                        'dbname'   => Request::$post->get('dbname')
                    ];
                    break;

                case "pdo_sqlite":
                    $info['path'] = Request::$post->get('path');
                    break;
            }

            try {
                // Lets try to do a few things with the database to confirm a connection.
                $db = ConnectionManager::create($info);
                $sm = $db->getSchemaManager();
                $sm->listTables();
            } catch (DBALException $e) {
                $errors[] = "Unable to connect to database: " . $e->getMessage();
            }
        }

        if (count($errors)) {
            $this->title("Database Information");
            return $this->render("steps/database_information.phtml", [
                'errors' => $errors
            ]);
        }

        $_SESSION['db'] = $info;
    }
protected function checkDatabaseInformation ( ) { $ this -> title ( "Database Information" ) ; $ errors = [ ] ; $ driver = Request :: $ post -> get ( 'driver' ) ; // Check fields if ( $ driver == "pdo_pgsql" || $ driver == "pdo_mysql" ) { if ( ! Request :: $ post -> get ( 'host' ) ) { $ errors [ ] = "Server is required" ; } if ( ! Request :: $ post -> get ( 'user' ) ) { $ errors [ ] = "Username is required" ; } if ( ! Request :: $ post -> get ( 'dbname' ) ) { $ errors [ ] = "Database name is required" ; } } elseif ( $ driver == "pdo_sqlite" ) { if ( ! Request :: $ post -> get ( 'path' ) ) { $ errors [ ] = "Database path is required" ; } } // Check connection if ( ! count ( $ errors ) ) { $ info = [ 'driver' => $ driver , ] ; switch ( $ driver ) { case "pdo_pgsql" : case "pdo_mysql" : $ info = $ info + [ 'host' => Request :: $ post -> get ( 'host' ) , 'user' => Request :: $ post -> get ( 'user' ) , 'password' => Request :: $ post -> get ( 'password' ) , 'dbname' => Request :: $ post -> get ( 'dbname' ) ] ; break ; case "pdo_sqlite" : $ info [ 'path' ] = Request :: $ post -> get ( 'path' ) ; break ; } try { // Lets try to do a few things with the database to confirm a connection. $ db = ConnectionManager :: create ( $ info ) ; $ sm = $ db -> getSchemaManager ( ) ; $ sm -> listTables ( ) ; } catch ( DBALException $ e ) { $ errors [ ] = "Unable to connect to database: " . $ e -> getMessage ( ) ; } } if ( count ( $ errors ) ) { $ this -> title ( "Database Information" ) ; return $ this -> render ( "steps/database_information.phtml" , [ 'errors' => $ errors ] ) ; } $ _SESSION [ 'db' ] = $ info ; }
Check the database form fields and connection.

@access protected
Check the database form fields and connection .