DatabaseFactory

Filepath: phork/php/database/DatabaseFactory.class.php

The DatabaseFactory loads the database configuration and instantiates and registers the correct type of database adaptor object based on the config. This is used in the bootstrap.


Example

//if the database is defined as enabled in the global config
if (AppConfig::get('DatabaseEnabled')) {

    //include the database factory class
    AppLoader::includeClass('php/database/', 'DatabaseFactory');
    
    //instantiate a new factory object using the config values from the config file passed (database.config.php)
    $objDatabaseFactory = new DatabaseFactory('database');
    
    //register a new database object generated by the database factory
    AppRegistry::register('Database', $objDatabaseFactory->init());
}