From 912cda9a1e4a9527c20a08e59ffcc8adb7a9257c Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sun, 16 Mar 2014 16:53:13 +1300 Subject: [PATCH] Close the mysqli connection when deleting the class. --- model/MySQLDatabase.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/model/MySQLDatabase.php b/model/MySQLDatabase.php index e35a92f2b..8e4ce3382 100644 --- a/model/MySQLDatabase.php +++ b/model/MySQLDatabase.php @@ -67,7 +67,7 @@ class MySQLDatabase extends SS_Database { } else { $this->dbConn = new MySQLi($parameters['server'], $parameters['username'], $parameters['password']); } - + if($this->dbConn->connect_error) { $this->databaseError("Couldn't connect to MySQL database | " . $this->dbConn->connect_error); } @@ -86,6 +86,12 @@ class MySQLDatabase extends SS_Database { } } + public function __destruct() { + if($this->dbConn) { + mysqli_close($this->dbConn); + } + } + /** * Not implemented, needed for PDO */