devilbox/.devilbox/www/htdocs/vendor/phpredmin/libraries/db.php
2018-08-12 10:51:32 +02:00

22 lines
645 B
PHP

<?php
final class db
{
protected static $_instances = array();
public static function factory($config, $driver = null)
{
$driver = isset($driver) ? $driver : App::instance()->config['database']['driver'];
$instanceName = $driver . ':' . $config['host'] . ':' . $config['port'];
if (!isset(self::$_instances[$instanceName])) {
include_once(App::instance()->drivers.'db/'.(strtolower($driver)).'.php');
$class = ucwords(strtolower($driver)).'Db';
self::$_instances[$instanceName] = new $class($config);
}
return self::$_instances[$instanceName];
}
}