Sets the DBMS Driver

@param \Niirrty\DB\Driver\IDriver $driver
@return \Niirrty\DB\Connection
486701
public function setDriver( IDriver $driver ) : Connection
   {

      $this->_driver = $driver;
      $this->_pdo    = null;

      return $this;

   }
1076337
private function driver() {
        $config = require(Dir::config());
        $db = $config['database'];

        switch(strtolower($db['driver'])) {
            case 'mysql':
                $driver = Dir::driverDatabase(ucwords(strtolower($db['driver'])));
                break;
            default:
                $driver = Dir::driverDatabase(ucwords(strtolower($db['driver'])));
                break;
        }

        return new $driver($db);
    }
640432
public function connect(): DriverInterface
    {
        // URL options
        $options = $this->getConfig()->get();

        // TODO: This option should be optional, in addition, it may not be an array
        // Driver options
        $optionsDriver = $options['driver_options']->get();

        try {
            $connection = new MongoManager(
                $this->getDsn(),
                $this->getOptions($options, self::AVAILABLE_OPTIONS),
                $this->getOptions($optionsDriver, self::AVAILABLE_DRIVER_OPTIONS)
            );
            $this->setInstance($connection);

        } catch (RuntimeException $e) {
            new Exception('Unable to connect');
        } catch (InvalidArgumentException $e) {
            new Exception('Invalid argument provided');
        }

        return $this;
    }
1221955
protected function createDriver($driver)
    {
        $config = config("payments.{$driver}", null);
        if (is_string($config)) {
            return $this->createDriver($config);
        }
        if ($config === null) {
            throw new InvalidArgumentException("Driver [$driver] not supported.");
        }
        $provider = $config['provider'] ?? null;

        // We'll check to see if a creator method exists for the given driver. If not we
        // will check for a custom driver creator, which allows developers to create
        // drivers using their own customized driver creator Closure to create it.
        if (isset($this->customCreators[$provider])) {
            $config['shop'] = $driver;
            return tap(
                $this->callCustomCreator($provider, $config),
                function (PaymentProviderInterface $provider) use ($driver) {
                    $provider->setLogger(
                        new Logger($driver, [new RotatingFileHandler(storage_path("logs/{$driver}.log"))])
                    );
                }
            );
        }
        throw new InvalidArgumentException("Provider [$provider] not supported.");
    }
1219208
public function connect($driverOptions = array()) {
        if ($this->pdo === null) {
            if (is_array($driverOptions) && !empty($driverOptions)) {
                $this->config['driverOptions']= array_merge($this->config['driverOptions'], $driverOptions);
            }
            try {
                $this->pdo= new \PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
            } catch (\PDOException $xe) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $xe->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            } catch (\Exception $e) {
                $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage(), '', __METHOD__, __FILE__, __LINE__);
                return false;
            }

            $connected= (is_object($this->pdo));
            if ($connected) {
                $connectFile = XPDO_CORE_PATH . 'om/' . $this->config['dbtype'] . '/connect.inc.php';
                if (!empty($this->config['connect_file']) && file_exists($this->config['connect_file'])) {
                    $connectFile = $this->config['connect_file'];
                }
                if (file_exists($connectFile)) include ($connectFile);
            }
            if (!$connected) {
                $this->pdo= null;
            }
        }
        $connected= is_object($this->pdo);
        return $connected;
    }
698077
protected function createDriver($driver)
    {
        // We'll check to see if a creator method exists for the given driver. If not we
        // will check for a custom driver creator, which allows developers to create
        // drivers using their own customized driver creator Closure to create it.
        if (isset($this->customCreators[$driver])) {
            return $this->callCustomCreator($driver);
        } else {
            $method = 'create' . Str::studly($driver) . 'Driver';

            if (method_exists($this, $method)) {
                return $this->$method();
            }
        }
        throw new InvalidArgumentException("Driver [$driver] not supported.");
    }
182227
public function setDriver($driver)
    {
        $driver = strtolower($driver);

        if (!in_array($driver, self::$allowedDrivers)) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s expects argument 1 to be one of %s, %s provided instead',
                __METHOD__,
                implode(',', self::$allowedDrivers),
                $driver
            ));
        }

        $this->driver = $driver;

        return $this;
    }
591208
protected function createDriver($driver)
	{
		$method = 'create'.ucfirst($driver).'Driver';

		// We'll check to see if a creator method exists for the given driver. If not we
		// will check for a custom driver creator, which allows developers to create
		// drivers using their own customized driver creator Closure to create it.
		if (isset($this->customCreators[$driver]))
		{
			return $this->callCustomCreator($driver);
		}
		elseif (method_exists($this, $method))
		{
			return $this->$method();
		}

		throw new \InvalidArgumentException("Driver [$driver] not supported.");
	}
1366888
public function setConnection($connection)
    {
        $this->connection = $connection;
        $this->database = DB::connection($this->connection);
        return $this;
    }
1066401
public function addDriver(string $name, DriverInterface $driver): DatabaseManager
    {
        if (isset($this->drivers[$name])) {
            throw new DBALException("Connection '{$name}' already exists");
        }

        $this->drivers[$name] = $driver;

        return $this;
    }
852555
public function setDriver($driver) {

    	if(false === is_string($driver)) {
    		return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($driver)), E_USER_ERROR);
    	}

        if(false === class_exists($driver)) {

            $driver = __NAMESPACE__ . '\\Driver\\' . $driver;
        
            if(false === class_exists($driver)) {
        		return trigger_error(sprintf('Driver "%s" does not exists', $driver), E_USER_ERROR);
        	}
        }

        $this -> driver = $driver;

        return $this;
    }
1217241
public static function factory($driver)
	{
		if (isset(static::$registrar[$driver]))
		{
			$resolver = static::$registrar[$driver];

			return $resolver();
		}

		switch ($driver)
		{
			case 'apc':
				return new Session\Drivers\APC(Cache::driver('apc'));

			case 'cookie':
				return new Session\Drivers\Cookie;

			case 'database':
				return new Session\Drivers\Database(Database::connection());

			case 'file':
				return new Session\Drivers\File(path('storage').'sessions'.DS);

			case 'memcached':
				return new Session\Drivers\Memcached(Cache::driver('memcached'));

			case 'memory':
				return new Session\Drivers\Memory;

			case 'redis':
				return new Session\Drivers\Redis(Cache::driver('redis'));

			default:
				throw new \Exception("Session driver [$driver] is not supported.");
		}
	}
835215
public function setDrivers(array $drivers)
    {
        $this->driverList = array();
        foreach ($drivers as $driver) {
            $this->addDriver($driver);
        }

        return $this;
    }
329348
protected function setup_driver( &$driver )
	{
		if ( !is_null( $this->config->path ) )
		{
			$driver->Sendmail = $this->config->path;
		}
	}
513248
public static function requireDriver($driver)
    {
        if (empty($driver)) {
            throw new \Exception("Database driver name can not be empty.");
        }

        // clients now use indirect association to drivers, dblib can be sqlsrv or sqlanywhere
        if ('dblib' === $driver) {
            $driver = 'sqlsrv';
        }
        $pdoDriver = null;
        switch ($driver) {
            case 'ibm':
                if (!extension_loaded('ibm_db2')) {
                    throw new \Exception("Required extension 'ibm_db2' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'ibm';
                break;
            case 'mysql':
                if (!extension_loaded('mysql') && !extension_loaded('mysqlnd')) {
                    throw new \Exception("Required extension 'mysql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'mysql';
                break;
            case 'oracle':
                if (!extension_loaded('oci8')) {
                    throw new \Exception("Required extension 'oci8' is not detected, but may be compiled in.");
                }
                break;
            case 'pgsql':
                if (!extension_loaded('pgsql')) {
                    throw new \Exception("Required extension 'pgsql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'pgsql';
                break;
            case 'sqlanywhere':
                $extension = 'mssql';
                if (!extension_loaded($extension)) {
                    throw new \Exception("Required extension 'mssql' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'dblib';
                break;
            case 'sqlite':
                if (!extension_loaded('sqlite3')) {
                    throw new \Exception("Required extension 'sqlite3' is not detected, but may be compiled in.");
                }
                $pdoDriver = 'sqlite';
                break;
            case 'sqlsrv':
                $pdoDriver = 'sqlsrv';
                $extension = 'sqlsrv';

                if (!extension_loaded($extension)) {
                    $pdoDriver = 'dblib';
                    $extension = 'mssql';
                    if (!extension_loaded($extension)) {
                        throw new \Exception("Required extension '$extension' is not detected, but may be compiled in.");
                    }
                }
                break;
            default:
                throw new \Exception("Driver '$driver' is not supported by this software.");
                break;
        }

        if ($pdoDriver) {
            static::checkForPdoDriver($pdoDriver);
        }

        return true;
    }
1206434
public function driver($driver = '')
    {
        if (isset($this->drivers[$driver]) || isset($this->extends[$driver])) {
            $driver = $this->buildDriver($driver);

            return $this->initalizeDriver($driver);
        } else {
            throw new DriverNotFoundException(sprintf('%s driver is not found', $driver));
        }
    }
413211
public function driver(?string $driver = null): self
    {
        $driver = $driver ? $driver : $this->app->make('config')->get('microservice-client.client');

        $connections = array_keys($this->app->make('config')->get('microservice-client.clients'));
        if (! in_array($driver, $connections, true)) {
            throw new DomainException("The Driver[{$driver}] not exists");
        }

        $this->driver = $driver;

        return $this;
    }