config() liest die Datenbank bei Bedarf selbst aus
bernd

bernd commited on 2009-12-05 16:28:20
Zeige 2 geänderte Dateien mit 10 Einfügungen und 12 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1527 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -5,18 +5,6 @@ require_once('inc/debug.php');
5 5
 require_once('inc/db_connect.php');
6 6
 require_once("inc/base.php");
7 7
 
8
-/*
9
- read configuration from database
10
-*/
11
-
12
-$options = db_query( "SELECT `key`, value FROM misc.config" );
13
-
14
-while( $object = mysql_fetch_assoc( $options ) ) {
15
-//	echo "1";
16
-//	echo $object['key'];
17
-	$config[$object['key']]=$object['value'];
18
-}
19
-//print_r($config);
20 8
 
21 9
 $go = $_GET['go'];
22 10
 
... ...
@@ -6,6 +6,16 @@ require_once('inc/db_connect.php');
6 6
 function config($key)
7 7
 {
8 8
   global $config;
9
+  if (array_key_exists($key, $config))
10
+    return $config[$key];
11
+  
12
+  /* read configuration from database */
13
+  $options = db_query( "SELECT `key`, value FROM misc.config" );
14
+  
15
+  while( $object = mysql_fetch_assoc( $options ) ) {
16
+	  $config[$object['key']]=$object['value'];
17
+  }
18
+  DEBUG($config);
9 19
   if (array_key_exists($key, $config))
10 20
     return $config[$key];
11 21
   else
12 22