refactoring database.

This commit is contained in:
Taylor Otwell
2011-08-19 21:18:59 -05:00
parent bf0aaa3cc7
commit 9d2a76b26f
8 changed files with 35 additions and 64 deletions

View File

@@ -5,12 +5,14 @@ class Factory {
/**
* Create a new database connector instance for a given driver.
*
* @param string $driver
* @param array $config
* @return Connector
*/
public static function make($driver)
public static function make($config)
{
switch ($driver)
if (isset($config['connector'])) return new Callback;
switch ($config['driver'])
{
case 'sqlite':
return new SQLite;
@@ -18,12 +20,11 @@ class Factory {
case 'mysql':
return new MySQL;
case 'postgres':
case 'pgsql':
return new Postgres;
default:
return new Generic;
}
throw new \Exception("Database configuration is invalid. Please verify your configuration.");
}
}