diff --git a/src/Database/Statement/MysqlStatement.php b/src/Database/Statement/MysqlStatement.php index 8587e4ab37c..ebbc052ff73 100644 --- a/src/Database/Statement/MysqlStatement.php +++ b/src/Database/Statement/MysqlStatement.php @@ -32,9 +32,14 @@ class MysqlStatement extends PDOStatement */ public function execute($params = null) { - $this->_driver->connection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $this->_bufferResults); - $result = $this->_statement->execute($params); - $this->_driver->connection()->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + $connection = $this->_driver->connection(); + + try { + $connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, $this->_bufferResults); + $result = $this->_statement->execute($params); + } finally { + $connection->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); + } return $result; }