refactor: s1_vdata queries cached and reused

#313
This commit is contained in:
Martin Ambrus
2017-11-20 10:10:29 +01:00
parent 0984c7ef34
commit 645793dde2
12 changed files with 548 additions and 388 deletions
+6 -5
View File
@@ -448,11 +448,12 @@ class adm_DB {
}
function search_village($village){
global $database;
$village = $database->escape($village);
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'";
$result = mysqli_query($this->connection, $q);
return $this->mysqli_fetch_all($result);
global $database;
$village = $database->escape($village);
$q = "SELECT * FROM ".TB_PREFIX."vdata WHERE `name` LIKE '%$village%' or `wref` LIKE '%$village%'";
$result = mysqli_query($this->connection, $q);
return $this->mysqli_fetch_all($result);
}
function search_alliance($alliance){
+7 -4
View File
@@ -85,7 +85,7 @@ class funct {
}
if (!$killhero){
$killhero=$database->FindHeroInOasis($get['uid']);
}
}
if ($killhero) {
$database->KillMyHero($get['uid']);
$error="&kc=1";
@@ -109,14 +109,17 @@ class funct {
case "addHero":
$user = $database->getUserArray($get['uid'],1);
$vilarray=$database->getVrefCapital($get['uid']);
if (!$vilarray) {
return;
}
$database->query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`,
`experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`,
`intraining`) VALUES (".(int) $get['uid'].", " . (int) $vilarray['wref'] . ", '0', ".(int) $get['u'].", '".addslashes($user['username'])."',
'0', '5', '0', '0', '100', '0', '0', '0', '0', '".time()."', '50', '0')");
$database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".(int) $vilarray['wref']);
header("Location: admin.php?p=player&uid=".$get['uid']."&ac=1");
exit;
}