From 86561be3ecdf3913544379db48fa77a1cac34352 Mon Sep 17 00:00:00 2001 From: shish Date: Sat, 28 Jul 2007 13:53:31 +0000 Subject: [PATCH] one less global git-svn-id: file:///home/shish/svn/shimmie2/trunk@389 7f39781d-f577-437e-ae19-be835c7a54ca --- core/config.class.php | 25 ++++++++++++------------- index.php | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/config.class.php b/core/config.class.php index 5d4a7bee..288ac537 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -1,28 +1,27 @@ values = $database->db->GetAssoc("SELECT name, value FROM config"); + public function Config($database) { + $this->database = $database; + $this->values = $this->database->db->GetAssoc("SELECT name, value FROM config"); } public function save($name=null) { - global $database; - if(is_null($name)) { foreach($this->values as $name => $value) { // does "or update" work with sqlite / postgres? - $database->db->StartTrans(); - $database->Execute("DELETE FROM config WHERE name = ?", array($name)); - $database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $value)); - $database->db->CommitTrans(); + $this->database->db->StartTrans(); + $this->database->Execute("DELETE FROM config WHERE name = ?", array($name)); + $this->database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $value)); + $this->database->db->CommitTrans(); } } else { - $database->db->StartTrans(); - $database->Execute("DELETE FROM config WHERE name = ?", array($name)); - $database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name])); - $database->db->CommitTrans(); + $this->database->db->StartTrans(); + $this->database->Execute("DELETE FROM config WHERE name = ?", array($name)); + $this->database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name])); + $this->database->db->CommitTrans(); } } diff --git a/index.php b/index.php index cd04aa1c..356add38 100644 --- a/index.php +++ b/index.php @@ -33,7 +33,7 @@ foreach($files as $filename) { $database = new Database(); $database->db->fnExecute = '_count_execs'; -$config = new Config(); +$config = new Config($database); $_theme = $config->get_string("theme", "default"); require_once "themes/$_theme/page.class.php"; require_once "themes/$_theme/layout.class.php";