FusionPBX 9 жил өмнө
parent
commit
550f378b0e

+ 20 - 10
resources/classes/domains.php

@@ -17,7 +17,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2014
+	Portions created by the Initial Developer are Copyright (C) 2008-2016
 	the Initial Developer. All Rights Reserved.
 
 	Contributor(s):
@@ -33,17 +33,19 @@ if (!class_exists('domains')) {
 
 		//class constructor
 		public function __construct() {
-			//connect to the database if not connected
-			if (!$this->db) {
-				require_once "resources/classes/database.php";
-				$database = new database;
-				$database->connect();
-				$this->db = $database->db;
-			}
+
 		}
 
 		public function set() {
 
+			//connect to the database if not connected
+				if (!$this->db) {
+					require_once "resources/classes/database.php";
+					$database = new database;
+					$database->connect();
+					$this->db = $database->db;
+				}
+
 			//set the PDO error mode
 				$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
@@ -202,7 +204,15 @@ if (!class_exists('domains')) {
 
 		public function upgrade() {
 
-			//get the db variables
+			//connect to the database if not connected
+				if (!$this->db) {
+					require_once "resources/classes/database.php";
+					$database = new database;
+					$database->connect();
+					$this->db = $database->db;
+				}
+
+			//get the variables
 				$config = new config;
 				$config_exists = $config->exists();
 				$config_path = $config->find();
@@ -357,4 +367,4 @@ if (!class_exists('domains')) {
 	}
 }
 
-?>
+?>