diff --git a/src/Pdo/PdoDriver.php b/src/Pdo/PdoDriver.php index d24e664ee..638c17200 100644 --- a/src/Pdo/PdoDriver.php +++ b/src/Pdo/PdoDriver.php @@ -448,22 +448,29 @@ public function execute() $errorMsg = (string) implode(', ', $this->statement->errorInfo()); // Check if the server was disconnected. - if (!$this->connected()) + try { - try + if (!$this->connected()) { - // Attempt to reconnect. - $this->connection = null; - $this->connect(); - } - catch (ConnectionFailureException $e) - { - // If connect fails, ignore that exception and throw the normal exception. - throw new ExecutionFailureException($sql, $errorMsg, $errorNum); - } + try + { + // Attempt to reconnect. + $this->connection = null; + $this->connect(); + } + catch (ConnectionFailureException $e) + { + // If connect fails, ignore that exception and throw the normal exception. + throw new ExecutionFailureException($sql, $errorMsg, $errorNum); + } - // Since we were able to reconnect, run the query again. - return $this->execute(); + // Since we were able to reconnect, run the query again. + return $this->execute(); + } + } + catch (\LogicException $e) + { + throw new ExecutionFailureException($sql, $errorMsg, $errorNum, $e); } // Throw the normal query exception. @@ -557,6 +564,7 @@ public static function isSupported() * @return boolean True if connected to the database engine. * * @since 1.0 + * @throws \LogicException */ public function connected() { @@ -566,8 +574,9 @@ public function connected() if ($checkingConnected) { // Reset this flag and throw an exception. - $checkingConnected = true; - die('Recursion trying to check if connected.'); + $checkingConnected = false; + + throw new \LogicException('Recursion trying to check if connected.'); } // Backup the query state.