Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 24, 2025
1 parent 9bb41a6 commit ae05e49
Showing 1 changed file with 59 additions and 59 deletions.
118 changes: 59 additions & 59 deletions src/Illuminate/Database/Connectors/PostgresConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,65 +50,6 @@ public function connect(array $config)
return $connection;
}

/**
* Set the connection transaction isolation level.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureIsolationLevel($connection, array $config)
{
if (isset($config['isolation_level'])) {
$connection->prepare("set session characteristics as transaction isolation level {$config['isolation_level']}")->execute();
}
}

/**
* Set the timezone on the connection.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureTimezone($connection, array $config)
{
if (isset($config['timezone'])) {
$timezone = $config['timezone'];

$connection->prepare("set time zone '{$timezone}'")->execute();
}
}

/**
* Set the "search_path" on the database connection.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureSearchPath($connection, $config)
{
if (isset($config['search_path']) || isset($config['schema'])) {
$searchPath = $this->quoteSearchPath(
$this->parseSearchPath($config['search_path'] ?? $config['schema'])
);

$connection->prepare("set search_path to {$searchPath}")->execute();
}
}

/**
* Format the search path for the DSN.
*
* @param array $searchPath
* @return string
*/
protected function quoteSearchPath($searchPath)
{
return count($searchPath) === 1 ? '"'.$searchPath[0].'"' : '"'.implode('", "', $searchPath).'"';
}

/**
* Create a DSN string from a configuration.
*
Expand Down Expand Up @@ -171,6 +112,65 @@ protected function addSslOptions($dsn, array $config)
return $dsn;
}

/**
* Set the connection transaction isolation level.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureIsolationLevel($connection, array $config)
{
if (isset($config['isolation_level'])) {
$connection->prepare("set session characteristics as transaction isolation level {$config['isolation_level']}")->execute();
}
}

/**
* Set the timezone on the connection.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureTimezone($connection, array $config)
{
if (isset($config['timezone'])) {
$timezone = $config['timezone'];

$connection->prepare("set time zone '{$timezone}'")->execute();
}
}

/**
* Set the "search_path" on the database connection.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureSearchPath($connection, $config)
{
if (isset($config['search_path']) || isset($config['schema'])) {
$searchPath = $this->quoteSearchPath(
$this->parseSearchPath($config['search_path'] ?? $config['schema'])
);

$connection->prepare("set search_path to {$searchPath}")->execute();
}
}

/**
* Format the search path for the DSN.
*
* @param array $searchPath
* @return string
*/
protected function quoteSearchPath($searchPath)
{
return count($searchPath) === 1 ? '"'.$searchPath[0].'"' : '"'.implode('", "', $searchPath).'"';
}

/**
* Configure the synchronous_commit setting.
*
Expand Down

0 comments on commit ae05e49

Please sign in to comment.