Browse Source

add disconnect to organizr class

CauseFX 4 years ago
parent
commit
4874b31710
1 changed files with 13 additions and 1 deletions
  1. 13 1
      api/classes/organizr.class.php

+ 13 - 1
api/classes/organizr.class.php

@@ -148,13 +148,18 @@ class Organizr
 		$this->checkIfUserIsBlacklisted();
 	}
 	
+	public function __destruct()
+	{
+		$this->disconnectDB();
+	}
+	
 	protected function connectDB()
 	{
 		if ($this->hasDB()) {
 			try {
 				$connect = [
 					'driver' => 'sqlite3',
-					'database' => $this->config['dbLocation'] . $this->config['dbName'],
+					'database' => $this->config['dbLocation'] . $this->config['dbName']
 				];
 				$this->db = new Connection($connect);
 			} catch (Dibi\Exception $e) {
@@ -165,6 +170,13 @@ class Organizr
 		}
 	}
 	
+	public function disconnectDB()
+	{
+		if ($this->hasDB()) {
+			$this->db->disconnect();
+		}
+	}
+	
 	public function connectOtherDB($file = null)
 	{
 		$file = $file ?? $this->config['dbLocation'] . 'tempMigration.db';