Create instance of configured PDO class.

@return PDO
548292
protected function createPDO(): PDO
    {
        return new PDO(
            $this->options['connection'] ?? $this->options['dsn'],
            $this->options['username'],
            $this->options['password'],
            $this->options['options']
        );
    }
1301509
protected function opendb() {
    // Only do one open
    
    if($this->db) {
      return $this->db;
    }
    //echo "$this->host, $this->user, $this->password";
    try {
      $db = @new PDO($this->host, $this->user, $this->password);
    } catch(PDOException $e) {
      $this->errno = $e->getCode();
      $this->error = $e->getMessage();
      throw new SqlException(__METHOD__.  " Connection failed: $this->host", $this);
    }

    $this->db = $db; // set this right away so if we get an error below $this->db is valid

    return $db;
  }
625074
private function createTokenServer()
    {
        // Catch errors for pdo object creation and creating the server
        try {
            // Create the server
            $storage = new \OAuth2\Storage\Pdo(
                [
                    'dsn' => $this->configuration->getDsn(),
                    'username' => $this->configuration->getUsername(),
                    'password' => $this->configuration->getPassword(),
                ]
            );
            $server = new \OAuth2\Server($storage);

            // Add grant types
            if ($this->configuration->getAuthorizationMode() === 1) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 2) {
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 3) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } else {
                throw new \Exception("Unknown authorization mode: \"{$this->configuration->getAuthorizationMode()}\".");
            }
        } catch (\Exception $ex) {
            throw $ex;
        }

        $this->tokenServer = $server;
        return $this;
    }
379962
public static function createSentry()
	{
		// Get some resources
		$ci =& get_instance();
		$ci->load->driver('session');

		// If Eloquent doesn't exist, then we must assume they are using their own providers.
		if (class_exists('Illuminate\Database\Eloquent\Model'))
		{
			$ci->load->database();

			// Let's connect and get the PDO instance
			$method = $ci->db->pconnect ? 'db_pconnect' : 'db_connect';
			$pdo = $ci->db->{$method}();

			// Validate PDO
			if ( ! $pdo instanceof PDO)
			{
				throw new \RuntimeException("Sentry will only work with PDO database connections.");
			}

			// Setup PDO
			foreach (static::$pdoOptions as $key => $value)
			{
				$pdo->setAttribute($key, $value);
			}

			$driverName  = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
			$tablePrefix = substr($ci->db->dbprefix('.'), 0, -1);

			Eloquent::setConnectionResolver(new ConnectionResolver($pdo, $driverName, $tablePrefix));
		}

		return new BaseSentry(
			$userProvider = new UserProvider(new NativeHasher),
			new GroupProvider,
			new ThrottleProvider($userProvider),
			new CISession($ci->session),
			new CICookie($ci->input),
			$ci->input->ip_address()
		);
	}
659767
public static function instance() {
        if (is_null(self::$_instance)) {
            if (Config::config()['user']['database']['enabled']) {
                self::$_instance = new Database();
            }
            else {
                self::$_instance = new Database();
            }
        }

        return self::$_instance;
    }
1222894
public function create()
    {
        $instance = self::createWishList($this);
        $this->setId($instance->getId());
        return $instance;
    }
1138163
private function getPdo()
    {
        static $pdo = null;

        if (is_null($pdo)) {
            $builder = new InstanceBuilder();
            $pdo = $builder->build('PDO', $this->args);
        }

        return $pdo;
    }
1013525
public function Connection() {
      $this->_IsPersistent = GetValue(PDO::ATTR_PERSISTENT, $this->ConnectionOptions, FALSE);
      if(!is_object($this->_Connection)) {
         try {
            $this->_Connection = new PDO(strtolower($this->Engine) . ':' . $this->Dsn, $this->User, $this->Password, $this->ConnectionOptions);
            $this->_Connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
            
            if($this->ConnectionOptions[1002])
               $this->Query($this->ConnectionOptions[1002]);
            
            // We only throw exceptions during connect
            $this->_Connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
         } catch (Exception $ex) {
            $Timeout = FALSE;
            if ($ex->getCode() == '2002' && preg_match('/Operation timed out/i', $ex->getMessage()))
               $Timeout = TRUE;
            if ($ex->getCode() == '2003' && preg_match("/Can't connect to MySQL/i", $ex->getMessage()))
               $Timeout = TRUE;
                    
            if ($Timeout)
               throw new Exception(ErrorMessage('Timeout while connecting to the database', $this->ClassName, 'Connection', $ex->getMessage()), 504);
            
            trigger_error(ErrorMessage('An error occurred while attempting to connect to the database', $this->ClassName, 'Connection', $ex->getMessage()), E_USER_ERROR);
         }
      }
      
      return $this->_Connection;
   }
411927
protected function createDatabaseDriver()
	{
		$connection = $this->getDatabaseConnection();

		$table = $connection->getTablePrefix().$this->app['config']['session.table'];

		return $this->buildSession(new PdoSessionHandler($connection->getPdo(), $this->getDatabaseOptions($table)));
	}
272795
public static function create(...$args) {
        list($table,$pk,$config) = $args;
        $class = get_called_class();
        if($table===null) {
            $class = explode('\\',$class);
            $table = end($class);
        }

        if(!$config) {
            throw new \Exception('dao config not exists!');
        }

        $class = static::parse(get_class(),$config);

        return new $class($table,$pk,$config);
    }
357831
public static function getConnection()
    {
        // DataBase constants
        require_once dirname(dirname(dirname(dirname(__DIR__)))).'/config/bdd.php';

        // Checks if Pdo connection doesn't exist
        if (is_null(self::$pdo)) {

            // Creates the first parameters for the new pdo concerning the database
            $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME;

            // Sets & stores the pdo options as the last parameters for the new pdo
            $options = [
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
            ];
            // Creates & stores the pdo connection
            $pdo = new PDO($dsn, DB_USER, DB_PASS, $options);

            // Sets the encoding characters
            $pdo->exec('SET NAMES UTF8');

            // Stores the pdo connection
            self::$pdo = $pdo;

            // Returns the connection
            return $pdo;
        } else {

            // Return the pdo connection
            return self::$pdo;
        }
    }
416801
public static function make()
    {
        $class = str_replace(
            'DatabaseManager',
            ucfirst(config('database.default')).'Database',
            self::class
        );

        try {
            return new self(new $class());
        } catch (\Exception $e) {
            return new self(new MysqlDatabase());
        }
    }
1040021
public static function getInstance(PDO $pdo, $table)
    {
        if (!self::$instance) {
            self::$instance = new self($pdo, $table);
        }
        return self::$instance;
    }
1090623
public function getPDO($name = null)
    {
        if (null === $name) {
            $name = $this->current ?: 'default';
        }
        if (!isset($this->connections[$name])) {
            $config = $this->configs[$name];
            $this->connections[$name] = new \PDO($config['dsn'], $config['username'], $config['password'], $config['options']);
        }

        return $this->connections[$name];
    }
706363
function new_instance()
	{
		$tab = $this->table_name();
		if(!$tab)
			bors_throw("Try to get new db instance with empty table_name()");

		if(!$this->get('create_time'))
			$this->set_create_time(time());

		if(!$this->get('modify_time'))
			$this->set_modify_time(time());

		$this->set('owner_id', bors()->user_id());
		$this->set('owner_ip', bors()->client()->ip());
		$this->set('last_editor_id', bors()->user_id());

		$this->storage()->create($this);
		$this->changed_fields = array();

		return $this;
	}
1090818
public static function loadPDO(PDO $connection)
    {
        $reflection = new ReflectionClass(static::class);
        $instance = $reflection->newInstanceWithoutConstructor();
        return $instance->connect($connection);
    }
500273
public static function getInstance(  ) { 
            
        if(!self::$objInstance){ 
            self::$options = array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
            );
            
            self::$objInstance = new PDO(PDOLITE_DB_DSN, PDOLITE_DB_USER, PDOLITE_DB_PASS, self::$options); 
        } 
        
        return self::$objInstance; 
    }