createDbo

@param string $driver
@param array  $options

@throws \RuntimeException
@return  AbstractDatabaseDriver
335910
public static function createDbo($driver, array $options)
    {
        // Sanitize the database connector options.
        $options['driver'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $driver);
        $options['database'] = $options['database'] ?? null;
        $options['select'] = $options['select'] ?? true;

        // Use custom Resource
        $resource = $options['resource'] ?? null;

        // Derive the class name from the driver.
        $class = '\\Windwalker\\Database\\Driver\\' . ucfirst(strtolower($options['driver'])) . '\\'
            . ucfirst(strtolower($options['driver'])) . 'Driver';

        // If the class still doesn't exist we have nothing left to do but throw an exception.  We did our best.
        if (!class_exists($class)) {
            throw new \RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
        }

        /** @var DatabaseDriverInterface $class */
        if (!$class::isSupported()) {
            throw new \RangeException('Database driver ' . $driver . ' not supported.');
        }

        // Create our new Driver connector based on the options given.
        try {
            $instance = new $class($resource, $options);
        } catch (\RuntimeException $e) {
            throw new \RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
        }

        return $instance;
    }
210440
public function createTable($table, $options)
    {
        $table = $this->buildRealTableName($table);
        $sql = $this->getSchema()->getCreateTableSql($table, $options);
        $ret = $this->query($sql);
        return $ret;
    }
692266
public function getConfig(string $driver = 'default'): IDataStore
    {
        if (!isset($this->config[$driver])) {
            if ($driver === 'default') {
                if (!isset($this->implicit['config'])) {
                    throw new \RuntimeException('The default config storage was not set');
                }
                $this->config[$driver] = $this->implicit['config'];
            } else {
                $this->config[$driver] = $this->getCollector()->getConfigDriver($driver);
            }
        }

        return $this->config[$driver];
    }
1332683
public function make(string $driver): ServiceDiscoverContract
    {
        $connections = $this->allConnections();

        switch ($driver) {
            case 'local':
                return new Local($this->app, $connections);
            case 'swarm':
                return new Swarm($this->app, $connections,
                    $this->app['client.manager'],
                    $this->app['cache']->store());
            case 'consul':
                return new Consul($this->app, $connections,
                    $this->app['client.manager'],
                    $this->app['cache']->store());
        }

        throw new InvalidArgumentException("Unsupported driver [{$driver}]");
    }
1012589
public function create(): Driver
    {
        if ($driver = $this->createDriverFromEnv()) {
            return $driver;
        }

        if (UvDriver::isSupported()) {
            return new UvDriver;
        }

        if (EvDriver::isSupported()) {
            return new EvDriver;
        }

        if (EventDriver::isSupported()) {
            return new EventDriver;
        }

        return new NativeDriver;
    }
822957
protected function createDriver($driver): Contracts\Factory
    {
        if (\is_null($this->setupDriverConfig($driver))) {
            throw new InvalidArgumentException("Driver [$driver] not supported.");
        }

        return new $this->resolver($this->app, $this, $driver);
    }
1184226
public static function getDb($driver = null, $option = [], $forceNew = false)
    {
        if (is_callable(static::$db)) {
            static::$db = call_user_func(static::$db);
        }

        if (!static::$db || $forceNew) {
            static::$db = DatabaseFactory::getDbo($driver, $option, $forceNew);
        }

        return static::$db;
    }
866183
protected function driverExcludedByOptions(string $driver, array $options): bool
    {
        return (! empty($options['only']) && ! \in_array($driver, (array) $options['only'])) ||
            (! empty($options['except']) && \in_array($driver, (array) $options['except']));
    }
331627
public static function create($table, $data, $option = false)
    {
        $db = self::Using(self::$using_dbo_id);
        return $db->create($table, $data, $option);
    }
1129146
public static function getDsn($driver, $options = [])
    {
        self::$options = $options;

        if (!is_callable([static::class, $driver])) {
            throw new \DomainException('The ' . $driver . ' driver is not supported.');
        }

        list($dsn, $replace) = static::$driver();

        $dsn = strtr($dsn, $replace);

        self::$options = [];

        return $dsn;
    }
811309
public function driver($driver = null)
    {
        $shortener = $this->app['config']['shortener'];

        $driver = $driver ?: $shortener['default'];

        $driverMethod = 'create'.ucfirst($driver).'Driver';

        if (method_exists($this, $driverMethod)) {
            return $this->{$driverMethod}($shortener);
        }

        throw new InvalidArgumentException("Driver [{$driver}] is not supported.");
    }
841287
public static function createFromResource(Resource $resource, array $options = [])
    {
        $entity = new self();

        $entity->applyResource($resource);

        return $entity;
    }
565174
public static function create(array $config = [])
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException("'driver' in config missing");
        }
        if (!isset($config['drivers'][$config['driver']])) {
            throw new InvalidArgumentException("driver '{$config['driver']}' is not configured");
        }
        if (!isset($config['drivers'][$config['driver']]['tagHeaderName'])) {
            throw new InvalidArgumentException("'tagHeaderName' is not configured");
        }

        $driverConfig = $config['drivers'][$config['driver']];
        $driverClass = $driverConfig['class'] ?? self::DRIVERS_NAMESPACE . '\\' . ucfirst($config['driver']);

        // tagHeaderName and tagHeaderDelimiter are not relevant to the Purger
        unset($driverConfig['tagHeaderName'], $driverConfig['tagHeaderDelimiter']);
        return \Craft::createObject($driverClass,[$driverConfig + ['useLocalTags' => $config['useLocalTags']]]);

    }
638986
private function doBulkCreate(Driver $driver)
    {
        $isInserted = array();
        $countData = 0;
        $modelClass = $this->crudConfigurator->getCrud()->getModelClass();
        $formRequests = $this->request->get('form');

        foreach ($formRequests as $formRequest) {
            /** @var ModelInterface $model */
            $model = new $modelClass();
            $form = $this->crudConfigurator->getForm($model);

            $form->submit($formRequest[$form->getName()]);
            if ($form->isValid()) {
                if (true === $this->crudOperationHandler->save($driver, $model)) {
                    $isInserted[] = $model->getId();
                }

                ++$countData;
            }
        }

        return array(
            'count' => $countData,
            'data' => $isInserted,
        );
    }
301156
public function createBuilder($type, array $options = [])
    {
        $metaType = $this->createType($type);
        $options = $this->getOptions($metaType, $options);

        $dataClass = isset($options['data_class']) ? $options['data_class'] : Meta::class;
        $builder = new MetaBuilder($this, $dataClass);
        $this->buildMeta($builder, $metaType, $options);

        return $builder;
    }
809111
public function prepare($sql, array $driverOptions = array())
    {
        $this->numStatements++;

        $pdos = $this->_pdo->prepare($sql, $driverOptions);
        
        return new PDOStatement($this, $pdos);
    }
487349
public function prepare($driver_options = array())
	{
		if ($this->query_sql === null) {
			$this->compile();
		}

		return $this->pdo->prepare($this->query_sql, $driver_options);
	}