devilbox/.devilbox/www/htdocs/vendor/phpredmin/libraries/db.php

22 lines
645 B
PHP
Raw Normal View History

2018-08-12 08:51:32 +00:00
<?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];
}
}