THIS FILE IS NOT USED BY COUGH -- CoughDatabaseFactory is used instead. This is simply part of the original "as_database" module.
A simple factory that provides access to an application's database objects. It should be dynamically initialized, and can hold mixed types of database objects (e.g. PEAR::DB, AS Database, DatabaseConnector, Persistent).
EXAMPLE INITIALIZATION:
As_DatabaseFactory::addDatabase('content', new As_Database('content')); As_DatabaseFactory::addDatabase('user', new As_Database('user')); As_DatabaseFactory::addDatabase('new_user', new As_Database('new_user'));
EXAMPLE RETRIEVAL:
$db = As_DatabaseFactory::getDatabase('content');
Alternatively, you can have databases added on the fly as you request them by specifying the configuration for each database:
Assuming we have:
$dbConfigs = array( 'foo' => array( 'db_name' => 'new_user', 'host' => 'localhost', 'user' => 'nobody', 'pass' => '', 'port' => 3307, ), 'user' => array( 'db_name' => 'user', 'host' => 'localhost', 'user' => 'nobody', 'pass' => '', 'port' => 3306, ) );
Option 1: Add one config at a time:
As_DatabaseFactory::addDatabaseConfig('foo', $dbConfigs['foo']); As_DatabaseFactory::addDatabaseConfig('user', $dbConfigs['user']);
Option 2: Add all configs at once:
As_DatabaseFactory::setDatabaseConfigs($dbConfigs);
Located in /as_database/As_DatabaseFactory.class.php (line 56)
An array of database config info.
When a database is retrieved, if it is not already created, then it gets created using the configuration info specified in this array, if that info exists.
Format:
[dbObjName] => array( 'db_name' => 'user', 'host' => 'localhost', 'user' => 'nobody', 'pass' => '', 'port' => 3306 );
Sets the database config for the specified database object name.
Sets all the database configs at once.
Documentation generated on Wed, 12 Nov 2008 21:56:10 -0600 by phpDocumentor 1.4.0