From eb7a05ea458f091e10cf2a10025fdae54db9e9e4 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sat, 10 Sep 2016 17:33:47 -0600 Subject: [PATCH] Update domains.php --- resources/classes/domains.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/resources/classes/domains.php b/resources/classes/domains.php index a5c745fc15..11f1275d25 100644 --- a/resources/classes/domains.php +++ b/resources/classes/domains.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - 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')) { } } -?> \ No newline at end of file +?>