src/ORM/DB.php
public static function connect($databaseConfig, $label = 'default')
    {
        // This is used by the "testsession" module to test up a test session using an alternative name
        if ($name = self::get_alternative_database_name()) {
            $databaseConfig['database'] = $name;
        }

        if (!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
            throw new InvalidArgumentException("DB::connect: Not passed a valid database config");
        }

        self::$connection_attempted = true;

        $dbClass = $databaseConfig['type'];

        // Using Injector->create allows us to use registered configurations
        // which may or may not map to explicit objects
        $conn = Injector::inst()->create($dbClass);
        self::set_conn($conn, $label);
        $conn->connect($databaseConfig);

        return $conn;
    }
public static function connect($databaseConfig, $label = 'default')
    {
        // This is used by the "testsession" module to test up a test session using an alternative name
        if ($name = self::get_alternative_database_name()) {
            $databaseConfig['database'] = $name;
        }

        if (!isset($databaseConfig['type']) || empty($databaseConfig['type'])) {
            throw new InvalidArgumentException("DB::connect: Not passed a valid database config");
        }

        self::$connection_attempted = true;

        $dbClass = $databaseConfig['type'];

        // Using Injector->create allows us to use registered configurations
        // which may or may not map to explicit objects
        $conn = Injector::inst()->create($dbClass);
        self::set_conn($conn, $label);
        $conn->connect($databaseConfig);

        return $conn;
    }
public static function connect ( $ databaseConfig , $ label = 'default' ) { // This is used by the "testsession" module to test up a test session using an alternative name if ( $ name = self :: get_alternative_database_name ( ) ) { $ databaseConfig [ 'database' ] = $ name ; } if ( ! isset ( $ databaseConfig [ 'type' ] ) || empty ( $ databaseConfig [ 'type' ] ) ) { throw new InvalidArgumentException ( "DB::connect: Not passed a valid database config" ) ; } self :: $ connection_attempted = true ; $ dbClass = $ databaseConfig [ 'type' ] ; // Using Injector->create allows us to use registered configurations // which may or may not map to explicit objects $ conn = Injector :: inst ( ) -> create ( $ dbClass ) ; self :: set_conn ( $ conn , $ label ) ; $ conn -> connect ( $ databaseConfig ) ; return $ conn ; }
Specify connection to a database

Given the database configuration, this method will create the correct
subclass of {@link SS_Database}.

@param array $databaseConfig A map of options. The 'type' is the name of the
subclass of SS_Database to use. For the rest of the options, see the specific class.
@param string $label identifier for the connection
@return Database
Specify connection to a database