Sfoglia il codice sorgente

add disconnect to organizr class

CauseFX 4 anni fa
parent
commit
4874b31710
1 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 13 1
      api/classes/organizr.class.php

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

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