create a pdo instance

@param array $config
@return PDO
@throws \PDOException
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);
    }
680510
protected function createSingleConnection(array $config)
    {
        $pdo = $this->createPdoResolver($config);

        return $this->createConnection(
            $config['driver'], $pdo, $config['database'], $config['prefix'], $config
        );
    }
361157
protected function createDataColumnByConfig(array $config = [])
    {
        return Yii::createObject(array_merge([
            'class' => $this->dataColumnClass ?: \yii\grid\DataColumn::class,
            'grid'  => $this,
        ], $config));
    }
466372
protected function createPdoResolverWithHosts( array $config )
	{
		return function () use ( $config ) {

			foreach( Arr::shuffle( $hosts = $this->parseHosts( $config ) ) as $key => $host )
			{
				$config['host'] = $host;
				try
				{
					return $this->createConnector( $config )->connect( $config );
				}
				catch( PDOException $e )
				{
					if( count( $hosts ) - 1 === $key )
					{
						App::Log($e);
					}
				}
			}

			if(!isset($e)) {
				$e = new PDOException("Empty connection");
			}

			throw $e;
		};
	}
122624
protected function createPdoResolver(array $config)
    {
        return array_key_exists('host', $config)
                            ? $this->createPdoResolverWithHosts($config)
                            : $this->createPdoResolverWithoutHosts($config);
    }
369641
public function make(array $config)
    {
        $client = $this->createClient($config);
        $zone = new ZoneRepository($client);
        $ip = new IpRepository($client);

        return new CloudFlareAPI($zone, $ip);
    }
988662
public function make(array $config)
    {
        $driver = $this->getDriver($config);

        // First we will check by the server driver type to see if an extension
        // has been registered specifically for that server.
        if (isset($this->serverExtensions[$driver])) {
            $server = call_user_func($this->serverExtensions[$driver], $config);
        }

        // Create a built-in server with given driver type.
        elseif (method_exists($this, $method = 'create'.Str::studly($driver).'Driver')) {
            $server = $this->$method($config);
        }

        // Otherwise, if the driver type does not support, an exception will be thrown.
        else {
            throw new InvalidArgumentException("Driver [{$driver}] is not supported.");
        }

        $this->configureServer($server, $config);

        return $server;
    }
892748
public static function instance(array $config = array())
    {
        if (!(self::$instance instanceof Phery)) {
            self::$instance = new Phery($config);
        } else if ($config) {
            self::$instance->config($config);
        }

        return self::$instance;
    }
409966
public function buildFromConfig(array $config, $id)
    {
        // generate the dsn needed for PDO
        if (isset($config['dsn'])) {
            $dsn = $config['dsn'];
        } else {
            $dsn = $this->buildDsn($config, $id);
        }

        $user = isset($config['user']) ? $config['user'] : null;
        $password = isset($config['password']) ? $config['password'] : null;
        $options = isset($config['options']) ? $config['options'] : [];

        $pdo = new PDO($dsn, $user, $password, $options);

        return new QueryBuilder($pdo);
    }
714786
public function connect(array $config)
    {
        $dsn = $this->getDsn($config);

        $options = $this->getOptions($config);

        // We need to grab the PDO options that should be used while making the brand
        // new connection instance. The PDO options control various aspects of the
        // connection's behavior, and some might be specified by the developers.
        $connection = $this->createConnection($dsn, $config, $options);

        if (! empty($config['database'])) {
            $connection->exec("use `{$config['database']}`;");
        }

        $this->configureEncoding($connection, $config);

        // Next, we will check to see if a timezone has been specified in this config
        // and if it has we will issue a statement to modify the timezone with the
        // database. Setting this DB timezone is an optional configuration item.
        $this->configureTimezone($connection, $config);

        $this->setModes($connection, $config);

        return $connection;
    }
1225801
public function prepare(array $config)
    {
        $new = array_merge($this->fields, $config);

        if (empty($new[self::CONFIG])) {
            $new[self::CONFIG] = $this->fieldsToConfig($new[self::FIELDS]);
        }

        return $new;
    }
226878
private function connect($config) {
		try {
			$this->pdoObject = new \PDO(
					$config["type"].':host=' . $config["serverName"] . ';dbname='
					. $config["dbName"] . ';port=' . $config["port"],
					$config["user"], $config["password"]);
			$this->pdoObject->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			$this->pdoObject->exec("SET CHARACTER SET utf8");

		} catch (\PDOException $e) {
			print "Error!: " . $e->getMessage() . "<br/>";
		}
	}
958420
public function make(array $config)
    {
        Arr::requires($config, ['token']);

        $client = new Client();

        return new PagerdutyGateway($client, $config);
    }
540100
public static function create(array $config)
    {
        if (!empty($config['url'])) {
            $config['app_id'] = substr(parse_url($config['url'], PHP_URL_PATH), 6);
            $config['key'] = parse_url($config['url'], PHP_URL_USER);
            $config['secret'] = parse_url($config['url'], PHP_URL_PASS);
            $config['scheme'] = parse_url($config['url'], PHP_URL_SCHEME);
            $config['host'] = parse_url($config['url'], PHP_URL_HOST);
            $config['port'] = parse_url($config['url'], PHP_URL_PORT) ?: $config['port'];
        }

        // For backwards compatibility with deprecated host argument
        if (preg_match('(^(https?://))', $config['host'], $matches)) {
            $config['scheme'] = substr($matches[0], 0, -3);
            $config['host'] = substr($config['host'], strlen($matches[0]));
        }

        return new Pusher(
            $config['key'],
            $config['secret'],
            $config['app_id'],
            [
                'scheme' => $config['scheme'],
                'host' => $config['host'],
                'port' => $config['port'],
                'timeout' => $config['timeout'],
                'cluster' => $config['cluster'],
                'debug' => $config['debug'],
            ]
        );
    }
876534
public function setHandler(array $config)
    {
        $connect = $config['connect'] ?? [];

        switch (strtolower($config['handler'])) {
            case 'redis':
                $class = Handler\Redis::class;
                $conn = Redis::client($connect);
                break;

            case 'simple':
            case 'simplecache':
                $class = Handler\SimpleCache::class;
                $conn = Cache::simple($connect);
                break;

            case 'cache':
                $class = Handler\Cache::class;
                $conn = Cache::pool($connect);
                break;

            case 'db':
                $class = Handler\Database::class;
                $conn = Database::pdo($connect);
                break;

            default:
                return;
        }

        $settings = $config['settings'] ?? [];
        if (!isset($settings['lifetime']) && isset($this->cookieParams['lifetime'])) {
            $settings['lifetime'] = $this->cookieParams['lifetime'];
        }

        $this->handler = new $class($conn, $settings);
    }
318965
public static function createApplication(array $config)
    {
        if (!isset($config['type'])) $config['type'] = 'unsupported';
        if (isset($config['class'])) {
            $className = $config['class'];
            return new $className($config);
        } else switch ($config['type']) {
            case 'web':
                return new WebApplication($config);
            default:
                throw new InvalidPropertyException([EntityType::APPLICATION, 'type']);
        }
    }
194801
protected function createSingleConnection($config)
    {
        $pdo = false;
        $connection = $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config);
        $connection->connect($config['host'], $config['username'], $config['password'], $config['database']);
        return $connection;
    }