db return DB instance initialized with `$dbConfig` given

@param ConfigInterface $dbConfig
@return DB
352043
public static function db(ConfigInterface $dbConfig)
    {
        $key = md5(json_encode($dbConfig->get()));
        if (!isset(self::$dbInstances[$key])) {
            self::$dbInstances[$key] = new DB($dbConfig);
        }

        return self::$dbInstances[$key];
    }
529887
public function connect( $config )
    {
        if ( $config !== NULL )
        {
            $this->host     = $config[ 'db_host' ];
            $this->user     = $config[ 'db_user' ];
            $this->password = $config[ 'db_pass' ];
            $this->name     = $config[ 'db_name' ];

            try
            {
                $dns = "mysql:host=" . $this->host . ";dbname=" . $this->name;

                $this->database = new PDO( $dns, $config[ 'db_user' ], $config[ 'db_pass' ] );
            }
            catch ( Exception $e )
            {
                throw new DatabaseException( $e->getMessage() );
            }
        }
    }
1176853
public function setInstance(DBInstance $instance, ConfigInterface $config)
    {
        $this->http = false;

        parent::setInstance($instance, $config);
        $this->setDispatcherClass(ArrayDispatcher::class);

        if (!class_exists('SoapClient')) {
            $this->getError()->setError('Class SoapClient not found. Please enable extension.');
        }

        return $this;
    }
1172219
public function db($conf = '')
    {
        $conf == '' && $conf = $this->getDbConf();
        if (is_array($conf)) {
            $config = $conf;
            $conf = md5(json_encode($conf));
        } else {
            $config = Config::get($conf);
        }
        $config['mark'] = $conf;

        if (isset($this->dbInstance[$conf])) {
            return $this->dbInstance[$conf];
        } else {
            $pos = strpos($config['driver'], '.');
            $this->dbInstance[$conf] = Cml::getContainer()->make('db_' . strtolower($pos ? substr($config['driver'], 0, $pos) : $config['driver']), $config);
            return $this->dbInstance[$conf];
        }
    }
258151
public function getDbFieldType() : string
    {
        $dbFieldType = $this->config->getProvider('dbFieldType');
        $dbFieldType = new $dbFieldType($this->config);
        $dbFieldType = $dbFieldType->provide();

        return $dbFieldType;
    }
207224
public static function instance()
    {
        if (empty(self::$databaseInstance)) {
            self::$databaseInstance = new static(self::$config);
        }
        return self::$databaseInstance;
    }
1241677
protected function getDbFactory() : FactoryInterface
    {
        $guess_config_in_dir    = getcwd();
        for($i = 0; $i < 3; $i++ ){
            $custom_config_path = $guess_config_in_dir . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'db-config.php';
            if(file_exists($custom_config_path)){
                break;
            }
            $guess_config_in_dir    = dirname($guess_config_in_dir);
        }
        if(file_exists($custom_config_path)){
            return include $custom_config_path;
        }
    }
1368858
public function createCommand($config = [])
    {
        $this->open();
        $config['db'] = $this;
        $command = new Command($config);

        return $command;
    }
536905
final public static function getDbInstance(string $databaseName = '#none'):\PDO
    {
        if (self::$co_instance == null) {
            new self($databaseName);
        }
        return (self::$co_instance);
    }
1242096
public static function initPdoDatabase($config, $name)
    {
        try {
            $pdo = static::createPdoConnectionByConfig($config);
        } catch (PDOException $e) {
            throw new Exception('Cannon instantiate database connection: ' . $e->getMessage());
        }

        $pdo->uniqueName = $config['host'] . "-" . $config['db'];

        static::checkDebugBar($pdo, $name);

        return new RepositoryPDO($pdo, $name);
    }
96145
public function create_database($dbhost, $dbuser, $dbpass, $dbname, array $dboptions=null) {
        global $CFG;

        $this->dbhost = $dbhost;
        $this->dbuser = $dbuser;
        $this->dbpass = $dbpass;
        $this->dbname = $dbname;
        $filepath = $this->get_dbfilepath();
        $dirpath = dirname($filepath);
        @mkdir($dirpath, $CFG->directorypermissions, true);
        return touch($filepath);
    }
500195
public static function setConfig(array $config)
    {
        if ( ! isset($config['connection'])) {
            throw new DbException('can`t find `connection` parameter in database config');
        }
        $connection = &$config['connection'];
        if ( ! isset($connection['default'])) {
            throw new DbException('can`t find `default` parameter in database config');
        }
        $default = &$connection['default'];
        if ( ! is_string($default) || empty($connection[$default])) {
            throw new DbException('parameter `default` must be string and contain contains name of default connection. So given section `' .
                $default .
                '` must present in database config');
        }

        return self::$config = $config;
    }
989039
public static function pdo(array $config = []): DB
    {
        [$hash, $config] = static::getKey($config, 'database');

        if (isset(static::$pool[$hash])) {
            return static::$pool[$hash];
        }

        $driver = $config['driver'] ?? '';

        if ($driver === 'develop' && !Debugger::$productionMode) {
            return static::$pool[$hash] = new Develop($config);
        }

        return static::$pool[$hash] = new DB($config);
    }
193351
public static function getInstance(Configuration $config = null)
    {
        if (!self::$instance) {
            self::$instance = new self($config);
        }

        return self::$instance;
    }
301252
public static function getInheritanceFinder(ConfigInterface $config) {
        if($config instanceof FileConfig){
            $cacheStrategy = new \Synga\InheritanceFinder\File\CacheStrategy($config);
        } elseif($config instanceof DatabaseConfig){
            $cacheStrategy = new \Synga\InheritanceFinder\Database\CacheStrategy($config);
        }

        return new \Synga\InheritanceFinder\InheritanceFinder(
            new \Synga\InheritanceFinder\CacheBuilder(
                $cacheStrategy,
                new PhpClassParser((new ParserFactory)->create(ParserFactory::PREFER_PHP7), new ClassNodeVisitor()),
                new \Symfony\Component\Finder\Finder(),
                new \Synga\InheritanceFinder\Helpers\FastArrayAccessHelper()
            )
        );
    }
463302
public function export_dbconfig() {
        $cfg = new stdClass();
        $cfg->dbtype    = $this->get_dbtype();
        $cfg->dblibrary = $this->get_dblibrary();
        $cfg->dbhost    = $this->dbhost;
        $cfg->dbname    = $this->dbname;
        $cfg->dbuser    = $this->dbuser;
        $cfg->dbpass    = $this->dbpass;
        $cfg->prefix    = $this->prefix;
        if ($this->dboptions) {
            $cfg->dboptions = $this->dboptions;
        }

        return $cfg;
    }
680057
public static function getDbo()
	{
		if (!self::$database)
		{
			//get config values

			$host = Config::get()->get('database.host');
			$user = Config::get()->get('database.user');
			$password = Config::get()->get('database.password');
			$database = Config::get()->get('database.name');
			$prefix = Config::get()->get('database.prefix');
			$driver = Config::get()->get('database.driver');
			$debug = Config::get()->get('database.debug');

			//added extra code to prevent error when $driver is incorrect

			$options = array('driver' => $driver, 'host' => $host, 'user' => $user, 'password' => $password, 'database' => $database, 'prefix' => $prefix);

			self::$database = DatabaseFactory::getInstance()->getDriver($driver, $options);

			//get the debug configuration setting
			self::$database->setDebug(Config::get()->get('debug'));
		}
		return self::$database;
	}