Create PDO Metadata DAO instance

@param  DriverConfig      $config
@return OracleMetaDataDAO
513459
public static function getInstance(DriverConfig $config)
    {
        $pdoDriver = PdoDriverFactory::getInstance();

        return new OracleMetaDataDAO(
            $pdoDriver->getConnection($config)
        );
    }
593700
public static function connect(ConnectionParameters $config){

		//Not static
		$con = new self();
		
		switch(\strtolower(\trim($config->getDriver()))){
			
			case 'sqlite':
				$con->Connection = new \PDO(
						\sprintf('sqlite:%s', $config->getHost()),
						$config->getUsername(),
						$config->getPassword(),
						$config->getOptions());
				break;
			
			default:
				$con->Connection = new \PDO(\sprintf(
						'%s:host=%s;charset=%s;dbname=%s',
						$config->getDriver() ? $config->getDriver() : '',
						$config->getHost() ? $config->getHost() : '',
						$config->getCharset() ? $config->getCharset() : '',
						$config->getDatabaseName() ? $config->getDatabaseName() : ''
					),
					$config->getUsername(),
					$config->getPassword(),
					$config->getOptions());
				break;
			
		}
		
		return $con;

	}
829717
protected function createSingleDriver(array $config)
    {
        return new Monolog($this->parseChannel($config), [
            $this->prepareHandler(
                new StreamHandler(
                    $config['path'], $this->level($config),
                    $config['bubble'] ?? true, $config['permission'] ?? null, $config['locking'] ?? false
                ), $config
            ),
        ]);
    }
619016
protected function createDatabaseDriver(array $config)
	{
		$connection = $this->app['db']->connection(array_get($config, 'connection'));

		return $this->repository(
			new DatabaseStore(
				$connection, $this->app['encrypter'], $config['table'], $this->getPrefix($config)
			)
		);
	}
369673
public static function createPdoConnectionByConfig($config)
    {
        $timezone = config('pckg.locale.timezone', 'Europe/Ljubljana');
        $charset = $config['charset'] ?? 'utf8';
        $partDb = isset($config['db'])
            ? ";dbname=" . $config['db']
            : '';
        $options = [
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = \'' . $timezone . '\';',
            PDO::ATTR_STRINGIFY_FETCHES => false,
            PDO::ATTR_EMULATE_PREPARES => false,
        ];

        return new PDO(
            "mysql:host=" . $config['host'] . ";charset=" . $charset . $partDb,
            $config['user'],
            $config['pass'],
            $options
        );
    }
1172987
public function init($config)
    {
        $this->pdo = null;

        $dns = '';
        if (is_array($config)) {
            $config += array('user' => null, 'password' => null);
            $dns = "{$config['type']}:host={$config['host']};port={$config['port']};dbname={$config['name']}";
        } else if (is_string($config)) {
            $dns = $config;
        } else if ($config instanceof PDO) {
            $this->pdo = $config;
            return $this;
        }

        try {

            // Use pipe for merging fields - sqlite compatibility
            $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET sql_mode='PIPES_AS_CONCAT'");
            $this->pdo = new PDO($dns, $config['user'], $config['password'], $options);
            $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        } catch (Exception $ex) {
            $this->pdo = null;
            throw new RuntimeException('Cannot connect to database: ' . $ex->getMessage());
        }

        return $this;
    }
1150392
public static function createConnectionObj($driver, array $config)
    {
        switch ($driver) {
            case 'mysql' :
                return new Mysql($config);
                break;
            case 'postgresql' :
                return new Postgresql($config);
                break;
            case 'sqlite' :
                return new Sqlite($config);
                break;
            case 'oracle' :
                return new Oracle($config);
                break;
            default :
                $debug_msg = "~/config/database.php文件配置错误！不支持的数据库驱动类型 - " . strval($driver);
                throw new \InvalidArgumentException($debug_msg);
        }
    }
375940
protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
    {
        if ($this->container->bound($key = "db.connection.{$driver}")) {
            return $this->container->make($key, [$connection, $database, $prefix, $config]);
        }

        switch ($driver) {
            case 'mysql':
                return new MySqlConnection($connection, $database, $prefix, $config);

            case 'pgsql':
                return new PostgresConnection($connection, $database, $prefix, $config);
        }

        return parent::createConnection($driver, $connection, $database, $prefix, $config);
    }
985338
protected function initDatabase( array $config )
    {
        if ( isset( $config[ 'db' ] ) )
        {
            if ( isset( $config[ 'db' ][ 'class' ] ) )
            {
                $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config )
                {
                    $class = $config[ 'db' ][ 'class' ];

                    return new $class( $config[ 'db' ] );
                }
                );
            }
            else
            {
                $this->bindShared( 'RawPHP\RawDatabase\Contract\IDatabase', function () use ( $config )
                {
                    return new Database( $config[ 'db' ] );
                }
                );
            }
        }

        $this->alias( 'RawPHP\RawDatabase\Contract\IDatabase', 'db' );
    }
470202
public static function create($type = null, array $config = []) {

	    if(!$type) {

	        if(!isset($config['dsn'])) {
	            throw new \Exception('No database type defined.');
            }

            if(preg_match('/^([a-z0-9]+):/i', trim($config['dsn']), $matches)) {
                $type = $matches[1];
            }
            else {
                throw new \Exception('No driver found in DSN.');
            }

        }

		$type = strtolower($type);

		if($type === 'propel') {

			// check whether Propel is available (assume Propel2)

            if(!class_exists('\\Propel\\Runtime\\Propel')) {
                throw new \Exception('Propel is configured as driver for vxPDO but not available in this application.');
            }

            $serviceContainer = \Propel\Runtime\Propel::getServiceContainer();

            // retrieve adapter information

            $adapterName = $serviceContainer->getAdapterClass();
            $dsnName = $serviceContainer->getDefaultDatasource();

            /* @var $connection \Propel\Runtime\Connection\ConnectionInterface */

            $connection = \Propel\Runtime\Propel::getConnection();

            if(!in_array($adapterName, ['mysql', 'pgsql'])) {

                throw new \Exception(sprintf("vxPDO accepts only mysql and pgsql as established connection drivers. The configured Propel connection '%s' uses '%s'.", $dsnName, $adapterName));

			}

			// @todo fugly like hell - perhaps some more concise solution exists

            preg_match('/dbname=([^;]+)/i', \Propel\Runtime\Propel::getConnectionManager($dsnName)->getConfiguration()['dsn'], $matches);
            $dbName = $matches[1] ?? '';

            $pdoConnection = new Propel2ConnectionWrapper($connection);
            $pdoConnection->setName($dsnName);
            $pdoConnection->setDbName($dbName);

            $className =
                __NAMESPACE__ .
                '\\Adapter\\' .
                ucfirst($adapterName);

            /* @var $vxPDO DatabaseInterface */

            $vxPDO = new $className();
            $vxPDO->setConnection($pdoConnection);

            return $vxPDO;

		}

		else {

			$className =
				__NAMESPACE__ .
				'\\Adapter\\' .
				ucfirst($type);
	
			// check whether driver is available
				
			if(!class_exists($className)) {
	
				throw new ConfigException(sprintf("No class for driver '%s' supported.", $type));
	
			}
				
			return new $className($config);

		}

	}
1234771
public function doConnect($config)
    {
        $connectionString = 'sqlite:' . $config['database'];
        return $this->container->build(
            '\PDO',
            array($connectionString, null, null, $config['options'])
        );
    }
992142
protected function createDatabaseDriver(array $config)
    {
        return new DatabaseRepository(
            $this->app['db']->connection(Arr::get($config, 'connection')),
            Arr::get($config, 'table')
        );
    }
1061581
public function init($dbConfig)
    {
        $profiler = new Profiler();

        if (isset($this->drivers[$dbConfig['driver']])) {
            $driverClass          = $this->drivers[$dbConfig['driver']];
            self::$driverInstance = $driverClass::getInstance();

            $profiler->getTimer()->start();
            self::$driverInstance->setup($dbConfig);

            $profilerOptions = [
                'type' => 'connection',
                'time' => $profiler->getTimer()->calculate()
            ];

            $profiler->setOptions('dbConnection', $profilerOptions);
            Safan::handler()->getObjectManager()->setObject('gapOrmProfiler', $profiler);
        } else {
            throw new DriverNotFound($dbConfig['driver']);
        }
    }
1058179
public function createConnector( array $config )
	{
		if( !isset( $config['driver'] ) )
		{
			throw new InvalidArgumentException( 'A driver must be specified.' );
		}

		if( $this->container->getIs( $key = "db.connector.{$config['driver']}" ) )
		{
			return $this->container->get( $key );
		}

		switch( $config[ 'driver' ] ) {
			case 'mysql':
				return new MySqlConnector;
			/* TODO add support
			 * case 'pgsql':
				return new PostgresConnector;*/
		}

		throw new InvalidArgumentException( "Unsupported driver [{$config['driver']}]" );
	}
497921
protected function createPdo(array $config)
    {
        $dsn        = $this->getHostDsn($config);
        $userName   = (isset($config['username']) ? $config['username'] : null);
        $password   = (isset($config['password']) ? $config['password'] : null);
        $options    = $this->getPdoOptions($config);

        return new PDO($dsn, $userName, $password, $options);
    }
1172806
protected function getDsn(array $config)
    {
        // First we will create the basic DSN setup as well as the port if it is in
        // in the configuration options. This will give us the basic DSN we will
        // need to establish the PDO connections and return them back for use.
        if ($this->prefersOdbc($config)) {
            return $this->getOdbcDsn($config);
        }

        if (in_array('sqlsrv', $this->getAvailableDrivers())) {
            return $this->getSqlSrvDsn($config);
        } else {
            return $this->getDblibDsn($config);
        }
    }
948929
public function getDriver(Container $config)
        {
            $connObject = new Configuration();
            $config = $config->assoc();

            // We map our config options to Doctrine's naming of them
            $connParamsMap = array(
                'database' => 'dbname',
                'username' => 'user',
                'hostname' => 'host',
                'pass'     => 'password'
            );

            foreach ($connParamsMap as $key => $param) {
                if (isset($config[$key])) {
                    $config[$param] = $config[$key];
                    unset($config[$key]);
                }
            }

            $type = isAke($config, 'type', 'pdo_mysql');

            $config['driver'] = $type;
            unset($config['type']);

            return DriverManager::getConnection($config, $connObject);
        }