added a silent query and added the use of it in some places (where db_query may fail)

main
hecht 8 years ago
parent 8c3d6e55e8
commit c92d45debd

@ -44,7 +44,7 @@ function checkAccessRights($user_id, $clan_chat_id) {
if($user_id == NULL) { if($user_id == NULL) {
return false; return false;
} }
$qry = db_query('SELECT clan_chat_id FROM clan_chatroom_clans cc INNER JOIN user u ON cc.clan_id = u.clan WHERE cc.clan_chat_id = ' . $clan_chat_id . ' and u.id = ' .$user_id); $qry = silent_query('SELECT clan_chat_id FROM clan_chatroom_clans cc INNER JOIN user u ON cc.clan_id = u.clan WHERE cc.clan_chat_id = ' . $clan_chat_id . ' and u.id = ' .$user_id);
if(!$qry) { if(!$qry) {
return false; return false;
} }

@ -468,7 +468,7 @@ 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 = db_query($sql); $qry = silent_query($sql);
if(!$qry) { if(!$qry) {
echo $sql .'<br>'; echo $sql .'<br>';
} }

@ -59,7 +59,7 @@ function getDefines($prefix = NULL) {
} }
$sql = 'SELECT * FROM defines WHERE editable = 1 AND ' . $appendix; $sql = 'SELECT * FROM defines WHERE editable = 1 AND ' . $appendix;
$qry = db_query(); $qry = silent_query();
if(!$qry) { if(!$qry) {
return 'Fehler in SQL-Anweisung'; return 'Fehler in SQL-Anweisung';
@ -79,7 +79,7 @@ function setDefine($key, $value) {
} }
// set where editable true // set where editable true
$sql = 'UPDATE defines SET `value` = \''.$value.'\' WHERE `key` = \''.$key.'\' AND editable = TRUE'; $sql = 'UPDATE defines SET `value` = \''.$value.'\' WHERE `key` = \''.$key.'\' AND editable = TRUE';
$qry = db_query($sql); $qry = silent_query($sql);
if(!$qry || db_affected_rows() == 0) { if(!$qry || db_affected_rows() == 0) {
return 'Konnte den define ' . $key . ' nicht auf ' . $value . ' setzen'; return 'Konnte den define ' . $key . ' nicht auf ' . $value . ' setzen';
} }

@ -187,8 +187,6 @@ function isEventToFetchAwaiting($charid) {
function getEventIdsToFetch($char_id) { function getEventIdsToFetch($char_id) {
$sql = 'SELECT event_id FROM event_chars e WHERE block_end < now() and abgeholt = FALSE AND char_id = ' .$char_id . ' ORDER BY event_id ASC'; $sql = 'SELECT event_id FROM event_chars e WHERE block_end < now() and abgeholt = FALSE AND char_id = ' .$char_id . ' ORDER BY event_id ASC';
$qry = db_query($sql); $qry = db_query($sql);
if(!$qry)
echo $sql . '<br>';
$result = array(); $result = array();
while ($row = mysqli_fetch_row($qry)) { while ($row = mysqli_fetch_row($qry)) {
@ -256,8 +254,6 @@ function abholenChar(array $user, $event_id, $char_id) {
// Okay and now we want to learn the attacks :) // Okay and now we want to learn the attacks :)
$sql = 'SELECT attack, count(attack) as anzahl FROM event_fight_rounds e where event_id = ' . $event_id . ' AND event_char_id = ' . $char_id . ' group by attack'; $sql = 'SELECT attack, count(attack) as anzahl FROM event_fight_rounds e where event_id = ' . $event_id . ' AND event_char_id = ' . $char_id . ' group by attack';
$qry = db_query($sql); $qry = db_query($sql);
if(!$qry)
echo $sql .'<br>';
$attacken_usage = array(); $attacken_usage = array();
while($row = mysqli_fetch_assoc($qry)) { while($row = mysqli_fetch_assoc($qry)) {
@ -268,8 +264,6 @@ function abholenChar(array $user, $event_id, $char_id) {
$sql = 'UPDATE event_chars SET abgeholt = TRUE WHERE char_id = ' . $char_id . ' AND event_id = ' . $event_id; $sql = 'UPDATE event_chars SET abgeholt = TRUE WHERE char_id = ' . $char_id . ' AND event_id = ' . $event_id;
$qry = db_query($sql); $qry = db_query($sql);
if(!$qry)
echo $sql .'<br>';
semaphoreDown($ressource); // free the previously reserved semaphore! semaphoreDown($ressource); // free the previously reserved semaphore!
return $fight_ids; // Return the fight ids that the char has participated in! return $fight_ids; // Return the fight ids that the char has participated in!
@ -319,8 +313,6 @@ function getEventFightIds($event_id) {
function getEventFightIdsByChar($event_id, $event_char_id) { function getEventFightIdsByChar($event_id, $event_char_id) {
$sql = 'SELECT event_fight_id FROM event_fight_rounds where event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id . ' AND `round` = 0 ORDER BY event_fight_id ASC'; $sql = 'SELECT event_fight_id FROM event_fight_rounds where event_id = ' . $event_id . ' AND event_char_id = ' . $event_char_id . ' AND `round` = 0 ORDER BY event_fight_id ASC';
$qry = db_query($sql); $qry = db_query($sql);
if(!$qry)
echo $sql . '<br>';
while($row = mysqli_fetch_assoc($qry)) { while($row = mysqli_fetch_assoc($qry)) {
$result[]= $row['event_fight_id']; $result[]= $row['event_fight_id'];
} }
@ -331,10 +323,6 @@ function getEventFightRoundData($event_id, $event_fight_id, $round) {
$sql = 'SELECT * FROM event_fight_rounds WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id . ' AND `round` = ' .$round; $sql = 'SELECT * FROM event_fight_rounds WHERE event_id = ' . $event_id . ' AND event_fight_id = ' . $event_fight_id . ' AND `round` = ' .$round;
$qry = db_query($sql); $qry = db_query($sql);
if(!$qry) {
echo $sql . '<br>';
return;
}
while($row = mysqli_fetch_assoc($qry)) { while($row = mysqli_fetch_assoc($qry)) {
$result[$row['event_char_id']] = $row; $result[$row['event_char_id']] = $row;
} }

@ -20,7 +20,7 @@ function convertLearnIDToAttackID (array $learnids, $char_id) {
$sql = 'SELECT id, at_id FROM lernen WHERE id IN ('.implode(',', $learnids).') AND besitzer = ' . $char_id; $sql = 'SELECT id, at_id FROM lernen WHERE id IN ('.implode(',', $learnids).') AND besitzer = ' . $char_id;
// echo $sql .'<br>'; // echo $sql .'<br>';
$qry = db_query($sql); $qry = silent_query($sql);
if (!$qry) { if (!$qry) {
return array(); return array();
} }

@ -6,10 +6,18 @@
* @author hecht * @author hecht
*/ */
function silent_query($sql) {
return mysqli_query($GLOBALS['main_db'], $sql);
}
function db_query($sql) { function db_query($sql) {
$qry = mysqli_query($GLOBALS['main_db'], $sql); $qry = mysqli_query($GLOBALS['main_db'], $sql);
if(!$qry) { if(!$qry) {
echo $sql . '<br>'; echo $sql . '<br>';
die('Query failed: '
.'<li>errorno='.mysqli_errno($GLOBALS['main_db'])
.'<li>error='.mysqli_error($GLOBALS['main_db'])
.'<li>query='.$query);
} }
return $qry; return $qry;
} }

@ -76,8 +76,6 @@ function schedule($script_name, array $parameters, $execution_time, $repeat_mode
*/ */
function getAllTaskIds() { function getAllTaskIds() {
$qry = db_query('SELECT task_id FROM tasking'); $qry = db_query('SELECT task_id FROM tasking');
if(!$qry)
return array();
$result = array(); $result = array();
while($row = mysqli_fetch_row($qry)) { while($row = mysqli_fetch_row($qry)) {
$result[] = $row[0]; $result[] = $row[0];
@ -93,8 +91,6 @@ function getPassedTaskIds($timestamp = NULL) {
$timestamp = time(); $timestamp = time();
} }
$qry = db_query('SELECT task_id FROM tasking WHERE schedule_time <= ' . $timestamp); $qry = db_query('SELECT task_id FROM tasking WHERE schedule_time <= ' . $timestamp);
if(!$qry)
return array();
$result = array(); $result = array();
while($row = mysqli_fetch_row($qry)) { while($row = mysqli_fetch_row($qry)) {
$result[] = $row[0]; $result[] = $row[0];
@ -108,8 +104,6 @@ function getPassedTaskIds($timestamp = NULL) {
*/ */
function getTask($task_id) { function getTask($task_id) {
$qry = db_query('SELECT * FROM tasking WHERE task_id = ' . $task_id); $qry = db_query('SELECT * FROM tasking WHERE task_id = ' . $task_id);
if(!$qry)
return null;
return mysqli_fetch_assoc($qry); return mysqli_fetch_assoc($qry);
} }

@ -130,7 +130,7 @@ function encryptPassword($password){
function getUserMetaData($userid) { function getUserMetaData($userid) {
$sql = 'SELECT * FROM user_meta_data WHERE user_id = ' . $userid; $sql = 'SELECT * FROM user_meta_data WHERE user_id = ' . $userid;
$qry = db_query($sql); $qry = silent_query($sql);
$result = array(); $result = array();
if(!$qry) if(!$qry)

Loading…
Cancel
Save