diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 55ee3412eda..f487ce0cfbd 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -98,13 +98,6 @@ class Connection implements DriverConnection /** @var ExpressionBuilder */ protected $_expr; - /** - * Whether or not a connection has been established. - * - * @var bool - */ - private $isConnected = false; - /** * The current auto-commit mode of this connection. * @@ -192,8 +185,7 @@ public function __construct( $this->params = $params; if (isset($params['pdo'])) { - $this->_conn = $params['pdo']; - $this->isConnected = true; + $this->_conn = $params['pdo']; unset($this->params['pdo']); } @@ -356,7 +348,7 @@ public function getExpressionBuilder() */ public function connect() { - if ($this->isConnected) { + if ($this->_conn !== null) { return false; } @@ -364,8 +356,7 @@ public function connect() $user = $this->params['user'] ?? null; $password = $this->params['password'] ?? null; - $this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); - $this->isConnected = true; + $this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); $this->transactionNestingLevel = 0; @@ -524,7 +515,7 @@ public function setAutoCommit($autoCommit) $this->autoCommit = $autoCommit; // Commit all currently active transactions if any when switching auto-commit mode. - if ($this->isConnected !== true || $this->transactionNestingLevel === 0) { + if ($this->_conn === null || $this->transactionNestingLevel === 0) { return; } @@ -689,7 +680,7 @@ public function fetchOne(string $query, array $params = [], array $types = []) */ public function isConnected() { - return $this->isConnected; + return $this->_conn !== null; } /** @@ -771,8 +762,6 @@ public function delete($tableExpression, array $identifier, array $types = []) public function close() { $this->_conn = null; - - $this->isConnected = false; } /**