debuggen der sql-anweisungen

main
radiskull 13 years ago
parent 745408426d
commit 22df503494

@ -12,6 +12,7 @@
include_once(ROOT_PATH.'/include/attackenset.inc.php');
include_once(ROOT_PATH.'/include/erstellfunctions.inc.php');
include_once(ROOT_PATH.'/include/designfunctions.inc.php');
include_once(ROOT_PATH.'/include/sqlwrapper.inc.php');
define('ACTION_EDIT', 'edit');
define('ACTION_CREATE', 'create');
@ -29,7 +30,7 @@ function getDropItemsAsOptions(){
union
SELECT id, item AS name, \'wochen_ware\' as tablename FROM wochen_markt w;';
$qry = mysql_query($query);
$qry = db_query($query);
// Damit waeren alle noetigen Datenbankaufrufe erledigt!
while($row = mysql_fetch_assoc($qry)){
$result[$index++] = '<option value=\''.$row['id'].','.$row['tablename'].'\'>'.$row['name'].'</option>';
@ -55,12 +56,12 @@ function istrinstr($source, $insert, $search) {
}
function getNPCUser() {
$qry = mysql_query('SELECT * FROM user WHERE nickname = "'.NPC_USER_NAME.'";');
$qry = db_query('SELECT * FROM user WHERE nickname = "'.NPC_USER_NAME.'";');
return mysql_fetch_assoc($qry);
}
function getNPCAttacks() {
$qry = mysql_query('SELECT name,id FROM attacken a WHERE info like "%NPC%";');
$qry = db_query('SELECT name,id FROM attacken a WHERE info like "%NPC%";');
$set = array();
while ($result = mysql_fetch_assoc($qry)) {
@ -73,7 +74,7 @@ function getNPCAttacks() {
function learnNewAttacks($charid, $att_ids) {
//auslesen der gelernten Attacken
$sql = 'SELECT at_id, id FROM lernen WHERE besitzer = '.$charid.' AND at_id in ('.implode(',', $att_ids).');';
$qry = mysql_query($sql);
$qry = db_query($sql);
$learned_atts = array();
while($result = mysql_fetch_assoc($qry)) {
@ -82,7 +83,7 @@ function learnNewAttacks($charid, $att_ids) {
//Namen der Attacken auslesen
$sql = 'SELECT id,name FROM attacken WHERE id in ('.implode(',', $att_ids).');';
$qry = mysql_query($sql);
$qry = db_query($sql);
$att_names = array();
while($result = mysql_fetch_assoc($qry)) {
@ -95,14 +96,14 @@ function learnNewAttacks($charid, $att_ids) {
* Keine Gute Lösung, es wird zwar von der db verhindert, dass doppelte Einträge gespeichert werden
* aber ungebrauchte Attacken werden so auch nicht gelöscht (höchstens der NPC wird gelöscht)
*/
mysql_query('INSERT INTO lernen(name,at_id,besitzer,aktiv) VALUES(\''.$att_names[$att].'\','.$att.','.$charid.',1);');
db_query('INSERT INTO lernen(name,at_id,besitzer,aktiv) VALUES(\''.$att_names[$att].'\','.$att.','.$charid.',1);');
}
}
}
function getAttackSet($charid, $att_ids) {
$sql = 'SELECT at_id, id FROM lernen WHERE besitzer = '.$charid.' AND at_id in ('.implode(',', $att_ids).');';
$qry = mysql_query($sql);
$qry = db_query($sql);
$learned_atts = array();
while($result = mysql_fetch_assoc($qry)) {
@ -149,7 +150,7 @@ function displayNPCInfo($action, $task, $charid) {
$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid;
//$sql = 'SELECT * FROM chars c inner join kampf_list kl on c.id = kl.charakter WHERE c.id ='.$charid;
$qry = mysql_query($sql);
$qry = db_query($sql);
$row = mysql_fetch_assoc($qry);
}
@ -250,7 +251,7 @@ function editNPC($charid, $data, $att_ids) {
$sql .= ' WHERE c.id=\''.$charid.'\'';
//echo $sql;
$u = mysql_query($sql);
$u = db_query($sql);
$log = 0;
if(mysql_affected_rows() == 0 || $u === FALSE) {
@ -265,7 +266,7 @@ function editNPC($charid, $data, $att_ids) {
//alter müll
$qry = 'UPDATE chars SET attacken=\''.implode(',', $attset).'\', '.
'attacken2=\''.implode(',', $attset).'\' WHERE id='.$charid.' LIMIT 1';
mysql_query($qry);
db_query($qry);
$log++;
echo "\t\t\t".'<tr><td colspan="2">Attacken übernommen!</td></tr>';
} else {
@ -292,14 +293,14 @@ function createNPC($data, $att_ids) {
if($success) {
//Char ID holen
$qry = mysql_query('SELECT id FROM chars c WHERE name = "'.$data['name'].'";');
$qry = db_query('SELECT id FROM chars c WHERE name = "'.$data['name'].'";');
$result = mysql_fetch_assoc($qry);
$char_id = $result['id'];
//zur Kampfliste hinzufügen :)
$sql = 'INSERT INTO kampf_list(kampfname,charakter,rasse,besitzer,zeit,zeit_rec,lvlmax,ip,lvlmin) VALUES("NPC Kampf",'.$char_id.',"NPC","'.NPC_USER_NAME.'",0,'.
$data['zeit_rec'].','.$data['lvlmax'].',0,'.$data['lvlmin'].');';
mysql_query($sql);
db_query($sql);
//drops hinzufügen :D
$sql = 'INSERT INTO npc_item(charakter,item,feld,mal,datensatz,wieviel,preis) VALUES('.$char_id;
@ -311,7 +312,7 @@ function createNPC($data, $att_ids) {
}
$sql .= ','.$data['drop_max'].',\''.$info[1].'\','.$data['drop_anzahl'].','.$data['preis'].');';
echo $sql;
mysql_query($sql);
db_query($sql);
//Attacksets soweit einbinden
$attset = buildAttackSet($char_id, $att_ids);
@ -326,7 +327,7 @@ function createNPC($data, $att_ids) {
//alter müll
$qry = 'UPDATE chars SET attacken=\''.implode(',', $attset).'\', '.
'attacken2=\''.implode(',', $attset).'\' WHERE id='.$char_id.' LIMIT 1';
mysql_query($qry);
db_query($qry);
}
}
echo "\t".'<tr><td colspan="2" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'?choose=npc">NPC Übersicht</a></td></tr>'."\n";
@ -336,7 +337,7 @@ function displayDeleteNPC($charid) {
$colspan = 1;
$sql = 'SELECT * FROM chars WHERE id = '.$charid;
$qry = mysql_query($sql);
$qry = db_query($sql);
$row = mysql_fetch_assoc($qry);
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">NPC löschen</h1></td></tr>'."\n";
@ -347,7 +348,7 @@ function displayDeleteNPC($charid) {
function deleteNPC($charid) {
$colspan = 1;
$sql = 'DELETE FROM chars WHERE id = '.$charid.';';
$qry = mysql_query($sql);
$qry = db_query($sql);
if($qry === FALSE || mysql_affected_rows() <= 0){
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center;color:red">Der NPC '.$row['name'].' konnte nicht gelöscht werden!</td></tr>'."\n";;
} else {
@ -361,7 +362,7 @@ function displayNPCOverview($page) {
$desc_array = array('id', 'Name', 'Level');
$sql = 'SELECT '.join($d_array,',').' from chars where rasse = \'NPC\' ORDER BY level, Name LIMIT '.($page*20).', 20';
$qry = mysql_query($sql);
$qry = db_query($sql);
$colspan = count($d_array);
echo "\t".'<tr><td colspan="'.$colspan.'"><h1 style="text-align:center">Übersicht</h1></td></tr>'."\n";;
echo "\t".'<tr>'."\n";
@ -389,7 +390,7 @@ function displayNPCOverview($page) {
echo "\t".'</tr>'."\n";
}
$total = mysql_num_rows(mysql_query('SELECT '.join($d_array,',').' from chars where rasse = \'NPC\''));
$total = mysql_num_rows(db_query('SELECT '.join($d_array,',').' from chars where rasse = \'NPC\''));
$url = '<a href="'.$_SERVER['PHP_SELF'].'?choose=npc&page=###PAGE###">###LABEL###</a>';
echo "\t".'<tr><td colspan="'.$colspan.'"><hr></td></tr>'."\n";
echo "\t".'<tr><td colspan="'.$colspan.'">'.displayPagelinksNew(20, $total, $page, $url).'</td></tr>'."\n";
@ -403,29 +404,33 @@ function displayNPC($action, $task, $charid, $table, $page, $data, $att_ids){
echo "\t".'<input type="hidden" name="choose" value="npc"></input>'."\n";
echo "\t".'<input type="hidden" name="charid" value="'.$charid.'"></input>'."\n";
echo "\t".'<table width="80%" border="0">'."\n";
if($action == ACTION_EDIT){
echo "\t".'<input type="hidden" name="action" value="'.ACTION_EDIT.'"></input>'."\n";
if($task == TASK_EDIT) {
editNPC($charid, $data, $att_ids);
displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
} else {
displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
}
} else if($action == ACTION_CREATE){
echo "\t".'<input type="hidden" name="action" value="'.ACTION_CREATE.'"></input>'."\n";
if($task == TASK_CREATE) {
createNPC($data, $att_ids);
} else {
displayNPCInfo(ACTION_CREATE, TASK_CREATE, $charid);
}
} else if($action == 'delete'){
if($task == 'dodelete') {
deleteNPC($charid);
} else {
displayDeleteNPC($charid);
}
} else{
displayNPCOverview($page);
switch ($action) {
case ACTION_EDIT:
echo "\t".'<input type="hidden" name="action" value="'.ACTION_EDIT.'"></input>'."\n";
if($task == TASK_EDIT) {
editNPC($charid, $data, $att_ids);
displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
} else {
displayNPCInfo(ACTION_EDIT, TASK_EDIT, $charid);
}
break;
case ACTION_CREATE:
echo "\t".'<input type="hidden" name="action" value="'.ACTION_CREATE.'"></input>'."\n";
if($task == TASK_CREATE) {
createNPC($data, $att_ids);
} else {
displayNPCInfo(ACTION_CREATE, TASK_CREATE, $charid);
}
break;
case 'delete':
if($task == 'dodelete') {
deleteNPC($charid);
} else {
displayDeleteNPC($charid);
}
break;
default:
displayNPCOverview($page);
}
echo "\t".'<tr><td colspan="'.$colspan.'" style="text-align:center"><a href="'.$_SERVER['PHP_SELF'].'">Zum Hauptmenu</a></td></tr>'."\n";
echo "\t".'</table>'."\n";

Loading…
Cancel
Save