From a6cd585315b6696539d43b6be06c94f203d8e7d5 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 14 Apr 2016 22:38:28 -0600 Subject: [PATCH] Update the constructor and $db connection handling in the groups and switch_settings classes. --- resources/classes/groups.php | 10 +++++++++- resources/classes/switch_settings.php | 10 +++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/resources/classes/groups.php b/resources/classes/groups.php index b3dd5e9f47..48848b47cf 100644 --- a/resources/classes/groups.php +++ b/resources/classes/groups.php @@ -34,11 +34,19 @@ */ class groups { + public $db; + /** * Called when the object is created */ public function __construct() { - //place holder + //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; + } } /** diff --git a/resources/classes/switch_settings.php b/resources/classes/switch_settings.php index 29ebf827f9..d60c4c6c21 100644 --- a/resources/classes/switch_settings.php +++ b/resources/classes/switch_settings.php @@ -16,9 +16,13 @@ class switch_settings { * Called when the object is created */ public function __construct() { - //set the database connection - global $db; - $this->db = $db; + //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; + } } /**