Skip to content

Commit

Permalink
Return a regular PDO object if a persistent connection is requested.
Browse files Browse the repository at this point in the history
Doctrine DBAL currently does not work with persistent connections.
doctrine/dbal#2315
  • Loading branch information
ikari7789 authored and andrew-miller-rakuten committed Dec 8, 2016
1 parent 81ed5cc commit 730a2cc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Illuminate/Database/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,29 @@ protected function tryAgainIfCausedByLostConnection(Exception $e, $dsn, $usernam
throw $e;
}

/**
* Determine if the connection is persistent or not.
*
* @param array $options
* @return bool
*/
protected function isPersistentConnection($options)
{
if (isset($options[PDO::ATTR_PERSISTENT]) && $options[PDO::ATTR_PERISISTENT]) {
return true;
}

return false;
}

/**
* Create a new PDO connection instance.
*
* @return \PDO
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
if (class_exists(PDOConnection::class)) {
if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
return new PDOConnection($dsn, $username, $password, $options);
}

Expand Down

0 comments on commit 730a2cc

Please sign in to comment.