Get the current PDO connection used for reading.

@return \PDO
18003
public function getReadPdo()
    {
        if ($this->transactions >= 1) {
            return $this->getPdo();
        }

        if ($this->readPdo instanceof Closure) {
            return $this->readPdo = call_user_func($this->readPdo);
        }

        return $this->readPdo ?: $this->getPdo();
    }
1185757
public function getDoctrineConnection()
    {
        if (is_null($this->doctrineConnection)) {
            $data                     = ['pdo' => $this->getPdo(), 'user' => $this->getConfig('username')];
            $this->doctrineConnection = new DoctrineConnection(
                $data,
                $this->getDoctrineDriver()
            );
        }

        return $this->doctrineConnection;
    }
509786
public function getConnection()
	{
		if ($this->connection === null)
		{
			$connection = null;

			// We will now provide the query grammar to the connection.
			switch ($this->driverName)
			{
				case 'mysql':
					$connection = '\Illuminate\Database\MySqlConnection';
					break;

				case 'pgsql':
					$connection = '\Illuminate\Database\PostgresConnection';
					break;

				case 'sqlsrv':
					$connection = '\Illuminate\Database\SqlServerConnection';
					break;

				case 'sqlite':
					$connection = '\Illuminate\Database\SQLiteConnection';
					break;

				default:
					throw new \InvalidArgumentException("Cannot determine grammar to use based on {$this->driverName}.");
					break;
			}
			
			$this->connection = new $connection($this->pdo, '', $this->tablePrefix);
		}

		return $this->connection;
	}
768745
public function getConnection()
    {
        if (!$this->connection) {
            if ($this->connectionName) {
                $this->connection = $this->mongator->getConnection($this->connectionName);
            } else {
                $this->connection = $this->mongator->getDefaultConnection();
            }
        }

        return $this->connection;
    }
1072417
public function getConnection()
    {
        if ($this->conn === false) {
            $this->conn = null;
            if ($this->url) {
                $buf = "Using database settings:\n"
                    . " URL: " . $this->url . "\n"
                    . ($this->userId ? " user: " . $this->userId . "\n" : "")
                . ($this->password ? " password: " . $this->password . "\n" : "");

                $this->log($buf, Project::MSG_VERBOSE);

                // Set user + password to null if they are empty strings
                if (!$this->userId) {
                    $this->userId = null;
                }
                if (!$this->password) {
                    $this->password = null;
                }
                try {
                    $this->conn = new PDO($this->url, $this->userId, $this->password);
                    $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                } catch (PDOException $x) {
                    $this->log("Unable to create a PDO connection: " . $x->getMessage(), Project::MSG_WARN);
                }
            }
        }

        return $this->conn;
    }
352610
public function connection()
    {
        if (!is_object($this->db)) {
            $this->db = new \MysqliDb();
            $this->db->addConnection($this->dbName, $this->database);
        }

        return $this;
    }
1134882
public static function getDefaultConnection()
    {
        if (self::$defaultConnection === null) {
            $databaseSettings = StemSettings::singleton();

            self::$defaultConnection = static::getConnection($databaseSettings);

            if ($databaseSettings->stickyWriteConnection) {
                self::$readOnlyConnection = self::$defaultConnection;
            }
        }

        return self::$defaultConnection;
    }
1037856
private function getConnection() {
        if ($this->connection === null) {
            $this->connection = DriverManager::getConnection($this->params, new Configuration());
        }

        return $this->connection;
    }
60568
private function _getCurrentData()
    {
        $cls = $this->_cls;
        if (!$this->_data) {
            $this->_data = $cls::executePrepared($this->_builder, $this->_vals);
        }
        return $this->_data->fetch(\PDO::FETCH_ASSOC);
    }
853622
public static function setConnection()
    {
        $dhost = getenv('DB_HOST');
        $dbase = getenv('DB_BASE');
        $duser = getenv('DB_USER');
        $dpass = getenv('DB_PASS');

        $opt = [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
            PDO::ATTR_EMULATE_PREPARES   => false,
        ];

        try {
            self::$pdo = new PDO("mysql:host=$dhost;dbname=$dbase", $duser, $dpass, $opt);
        } catch (\Exception $exception) {
            var_dump($exception->getMessage());
            exit();
        }
    }
18588
public function getConnection() {
		try {
			$pdo = null;

			switch($this->driver){
				case "pdo_mysql": // MySQL Database
					$pdo = new PDO("mysql:host=".$this->host.";dbname=".$this->database.";charset=utf8", $this->user, $this->password);
					break;
				case "pdo_sqlserver": // SQL Server Database
					$pdo = new PDO("sqlsrv:Server=".$this->host.";Database=".$this->database, $this->user, $this->password);
					break;
				case "pdo_sqlite": // SQLite Database
				    $pdo = new PDO("sqlite:{$this->database}");
					break;
				case "pdo_pgsql": // PostgreSQL Database
				    $pdo = new PDO("pgsql:dbname={$this->database};host={$this->host}", $this->user, $this->password);
				    break;
				case "pdo_oci": // Oracle Database
					$tns = "oci:dbname=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = {$this->host}) (Port = {$this->port}))) (CONNECT_DATA = (SERVICE_NAME = {$this->database})))";
					$pdo = new PDO($tns, $this->user, $this->password);
					break;
				default:
					throw new  Exception("Database driver not defined");
				}

				if (count($this->attributes) > 0) {
					foreach ($this->attributes as $key => $value) {
						$pdo->setAttribute($key, $value);
					}
				}

				$this->pdo = $pdo;

				return $pdo;

		} catch (PDOException $e) {
			throw new PDOException('Unable to connect to database, errorMessage = '.$e->getMessage());
		} catch (Exception $e) {
			throw new Exception('Internal error, errorMessage = '.$e->getMessage());
		}
	}
469070
public function getDb(): ?ConnectionInterface
    {
        if (!$this->hasDb()) {
            $this->setDb($this->getDefaultDb());
        }
        return $this->db;
    }
1163073
public function connection()
    {
        // Build of the mysql dsn
        if (isset($this->config['socket']) && !is_null($this->config['socket']) && !empty($this->config['socket'])) {
            $hostname = $this->config['socket'];
        } else {
            $hostname = $this->config['hostname'];
        }

        $port = '';

        if ($hostname !== 'localhost' || $hostname == '127.0.0.1') {
            if (isset($this->config['port']) && !is_null($this->config['port']) && !empty($this->config['port'])) {
                $port = ':'.$this->config['port'];
            } else {
                $port = ':'.self::PORT;
            }
        }

        // Formatting connection parameters
        $host  = "mysql:host=".$hostname.$port;

        $database = "dbname=".$this->config['database'];

        $username = $this->config["username"];

        $password = $this->config["password"];

        // Configuration extra PDO side
        $options = [
            PDO::ATTR_DEFAULT_FETCH_MODE => isset($this->config['fetch']) ? $this->config['fetch'] : $this->fetch,
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . Str::upper($this->config["charset"]),
            PDO::ATTR_ORACLE_NULLS => PDO::NULL_EMPTY_STRING
        ];

        $this->pdo = new PDO($host.';'.$database, $username, $password, $options);
    }
1109675
public function getPdo()
    {
        if ($this->pdo === null) {
            $this->pdo = $this->doConnect();
        }
        return $this->pdo;
    }
1090818
public static function loadPDO(PDO $connection)
    {
        $reflection = new ReflectionClass(static::class);
        $instance = $reflection->newInstanceWithoutConstructor();
        return $instance->connect($connection);
    }
170293
public function getConnectionString()
    {
        $this->parseDsn();
        $connect_parameters = [
            sprintf(
                "user=%s dbname=%s",
                $this->configuration['user'],
                $this->configuration['database']
            )
        ];

        if ($this->configuration['host'] !== '') {
            $connect_parameters[] = sprintf('host=%s', $this->configuration['host']);
        }

        if ($this->configuration['port'] !== '') {
            $connect_parameters[] = sprintf('port=%s', $this->configuration['port']);
        }

        if ($this->configuration['pass'] !== '') {
            $connect_parameters[] = sprintf('password=%s', addslashes($this->configuration['pass']));
        }

        return join(' ', $connect_parameters);
    }
364007
public function getConnection()
    {
        if ($this->connection instanceof ConnectionInterface === FALSE)
        {
            $this->connection = Propel::getConnection();
        }

        return $this->connection;
    }