From 1318a84ea19f233c9f2e871cf5f889568357e4f1 Mon Sep 17 00:00:00 2001 From: hecht Date: Sun, 11 Dec 2011 14:29:06 +0000 Subject: [PATCH] inserted a wrapper method for query the database --- ag/include/clan_fights.inc.php | 3 +++ ag/include/config.inc.php | 1 + ag/include/defines.inc.php | 45 +++++++++++++++++++++++++++++++++- ag/include/sqlwrapper.inc.php | 18 ++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 ag/include/sqlwrapper.inc.php diff --git a/ag/include/clan_fights.inc.php b/ag/include/clan_fights.inc.php index 2f8d52c..1ab2a00 100644 --- a/ag/include/clan_fights.inc.php +++ b/ag/include/clan_fights.inc.php @@ -467,6 +467,9 @@ function getParticipatingClanIDs($clan_challenge_id) { function getParticipatingClanData($clan_challenge_id, $clan_id) { $sql = 'SELECT * FROM clan_challenge_clans AS ccp WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = ' .$clan_id; $qry = mysql_query($sql); + if(!$qry) { + echo $sql .'
'; + } return mysql_fetch_assoc($qry); } diff --git a/ag/include/config.inc.php b/ag/include/config.inc.php index 51217b5..d4860e5 100644 --- a/ag/include/config.inc.php +++ b/ag/include/config.inc.php @@ -15,6 +15,7 @@ include_once (ROOT_PATH . '/include/config/db.inc.php'); include_once (ROOT_PATH . '/include/config/server.inc.php'); include_once (ROOT_PATH . '/include/config/settings.inc.php'); +include_once (ROOT_PATH . '/include/sqlwrapper.inc.php'); include_once (ROOT_PATH . '/include/speed_config.inc.php'); include_once (ROOT_PATH . '/include/online.inc.php'); include_once (ROOT_PATH . '/include/parse.inc.php'); diff --git a/ag/include/defines.inc.php b/ag/include/defines.inc.php index 8d5940e..b4fab97 100644 --- a/ag/include/defines.inc.php +++ b/ag/include/defines.inc.php @@ -6,7 +6,8 @@ * */ -include_once (ROOT_PATH.'/include/config/db.inc.php'); +include_once (ROOT_PATH. '/include/config/db.inc.php'); +include_once (ROOT_PATH.'/include/sqlwrapper.inc.php'); $GLOBALS['definesInitialized'] = FALSE; @@ -44,4 +45,46 @@ function defineIfNotDefined($key, $value, $editable = TRUE) { } +function getDefines($prefix = NULL) { + if(!$GLOBALS['definesInitialized']) { + initializeDefines(); + } + + $appendix = NULL; + // readout the database (where editable true) + if($prefix === NULL) { + $appendix = '1'; + } else { + $appendix = 'key like \''.$prefix.'%\''; + } + + $sql = 'SELECT * FROM defines WHERE editable = 1 AND ' . $appendix; + $qry = db_query(); + + if(!$qry) { + return 'Fehler in SQL-Anweisung'; + } + + $result = array(); + while($row = mysql_fetch_assoc($qry)) { + $result[] = $row; + } + + return $result; +} + +function setDefine($key, $value) { + if(!$GLOBALS['definesInitialized']) { + initializeDefines(); + } + // set where editable true + $sql = 'UPDATE defines SET `value` = \''.$value.'\' WHERE `key` = \''.$key.'\' AND editable = TRUE'; + $qry = db_query($sql); + if(!$qry || mysql_affected_rows() == 0) { + return 'Konnte den define ' . $key . ' nicht auf ' . $value . ' setzen'; + } + return NULL; +} + + ?> \ No newline at end of file diff --git a/ag/include/sqlwrapper.inc.php b/ag/include/sqlwrapper.inc.php new file mode 100755 index 0000000..12a6649 --- /dev/null +++ b/ag/include/sqlwrapper.inc.php @@ -0,0 +1,18 @@ +'; + } + return $qry; +} + + + ?> \ No newline at end of file