inserted a wrapper method for query the database

main
hecht 13 years ago
parent f42a356499
commit 1318a84ea1

@ -467,6 +467,9 @@ function getParticipatingClanIDs($clan_challenge_id) {
function getParticipatingClanData($clan_challenge_id, $clan_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; $sql = 'SELECT * FROM clan_challenge_clans AS ccp WHERE clan_challenge_id = ' . $clan_challenge_id . ' AND clan_id = ' .$clan_id;
$qry = mysql_query($sql); $qry = mysql_query($sql);
if(!$qry) {
echo $sql .'<br>';
}
return mysql_fetch_assoc($qry); return mysql_fetch_assoc($qry);
} }

@ -15,6 +15,7 @@
include_once (ROOT_PATH . '/include/config/db.inc.php'); include_once (ROOT_PATH . '/include/config/db.inc.php');
include_once (ROOT_PATH . '/include/config/server.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/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/speed_config.inc.php');
include_once (ROOT_PATH . '/include/online.inc.php'); include_once (ROOT_PATH . '/include/online.inc.php');
include_once (ROOT_PATH . '/include/parse.inc.php'); include_once (ROOT_PATH . '/include/parse.inc.php');

@ -7,6 +7,7 @@
*/ */
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; $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;
}
?> ?>

@ -0,0 +1,18 @@
<?php
/*
*
* @copyright (c) 2011 animegame.eu
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
* @author hecht
*/
function db_query($sql) {
$qry = mysql_query($sql);
if(!$qry) {
echo $sql . '<br>';
}
return $qry;
}
?>
Loading…
Cancel
Save