Оптимизация запросов в БД.

This commit is contained in:
lopar 2018-02-28 23:16:09 +02:00
parent fae934f0ad
commit 3e51461e6e
3 changed files with 97 additions and 92 deletions

View File

@ -1,7 +1,10 @@
<?php <?php
include 'config.php'; include '../config.php';
include 'functions.php'; //include '../functions.php';
showinf_pers(10736,1); //showinf_pers(10736,1);
showinf_pers(10736); //showinf_pers(10736);
$row = db::c()->query('select * from `bank` WHERE owner=10929 OR owner=11221')->fetch_assoc_array();
print_r($row);

164
bank.php
View File

@ -184,88 +184,88 @@ if (!$_SESSION['bankid']) {
$user1 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='" . $user['id'] . "' LIMIT 1;")); $user1 = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='" . $user['id'] . "' LIMIT 1;"));
$svstats = $user1['sila'] + $user1['lovk'] + $user1['inta'] + $user1['vinos'] + $user1['intel'] + $user1['mudra'] - 12 - $user1['level']; $svstats = $user1['sila'] + $user1['lovk'] + $user1['inta'] + $user1['vinos'] + $user1['intel'] + $user1['mudra'] - 12 - $user1['level'];
if ($svstats <= $bank['ekr']) { if ($svstats <= $bank['ekr']) {
$exps = array("20" => array(15), $exps = ["20" => [15],
"45" => array(16), "45" => [16],
"75" => array(17), "75" => [17],
"110" => array(18), "110" => [18],
"160" => array(21), "160" => [21],
"215" => array(22), "215" => [22],
"280" => array(23), "280" => [23],
"350" => array(24), "350" => [24],
"410" => array(25), "410" => [25],
"530" => array(28), "530" => [28],
"670" => array(29), "670" => [29],
"830" => array(30), "830" => [30],
"950" => array(31), "950" => [31],
"1100" => array(32), "1100" => [32],
"1300" => array(33), "1300" => [33],
"1450" => array(36), "1450" => [36],
"1650" => array(37), "1650" => [37],
"1850" => array(38), "1850" => [38],
"2050" => array(39), "2050" => [39],
"2200" => array(40), "2200" => [40],
"2500" => array(41), "2500" => [41],
"2900" => array(46), "2900" => [46],
"3350" => array(47), "3350" => [47],
"3800" => array(48), "3800" => [48],
"4200" => array(49), "4200" => [49],
"4600" => array(50), "4600" => [50],
"5000" => array(51), "5000" => [51],
"6000" => array(54), "6000" => [54],
"7000" => array(55), "7000" => [55],
"8000" => array(56), "8000" => [56],
"9000" => array(57), "9000" => [57],
"10000" => array(58), "10000" => [58],
"11000" => array(59), "11000" => [59],
"12000" => array(60), "12000" => [60],
"12500" => array(61), "12500" => [61],
"14000" => array(64), "14000" => [64],
"15500" => array(65), "15500" => [65],
"17000" => array(66), "17000" => [66],
"19000" => array(67), "19000" => [67],
"21000" => array(68), "21000" => [68],
"23000" => array(69), "23000" => [69],
"26000" => array(70), "26000" => [70],
"30000" => array(71), "30000" => [71],
"60000" => array(76), "60000" => [76],
"75000" => array(77), "75000" => [77],
"150000" => array(78), "150000" => [78],
"175000" => array(79), "175000" => [79],
"200000" => array(80), "200000" => [80],
"225000" => array(81), "225000" => [81],
"250000" => array(82), "250000" => [82],
"260000" => array(83), "260000" => [83],
"280000" => array(84), "280000" => [84],
"300000" => array(85), "300000" => [85],
"1500000" => array(86), "1500000" => [86],
"1750000" => array(87), "1750000" => [87],
"2000000" => array(88), "2000000" => [88],
"2175000" => array(89), "2175000" => [89],
"2300000" => array(90), "2300000" => [90],
"2400000" => array(91), "2400000" => [91],
"2500000" => array(92), "2500000" => [92],
"2600000" => array(93), "2600000" => [93],
"2800000" => array(94), "2800000" => [94],
"3000000" => array(95), "3000000" => [95],
"6000000" => array(96), "6000000" => [96],
"6500000" => array(97), "6500000" => [97],
"7500000" => array(98), "7500000" => [98],
"8500000" => array(99), "8500000" => [99],
"9000000" => array(100), "9000000" => [100],
"9250000" => array(101), "9250000" => [101],
"9500000" => array(102), "9500000" => [102],
"9750000" => array(103), "9750000" => [103],
"9900000" => array(104), "9900000" => [104],
"10000000" => array(105), "10000000" => [105],
"13000000" => array(106), "13000000" => [106],
"14000000" => array(107), "14000000" => [107],
"15000000" => array(108), "15000000" => [108],
"16000000" => array(109), "16000000" => [109],
"17000000" => array(110), "17000000" => [110],
"17500000" => array(111), "17500000" => [111],
"18000000" => array(112), "18000000" => [112],
"19000000" => array(113), "19000000" => [113],
"19500000" => array(114)); "19500000" => [114]];
echo "<pre>"; echo "<pre>";
$ss = mysql_query("SELECT `id`,`nextup`,`level` FROM `users` WHERE `level` > 0 AND `level` < 8 AND id='" . $user['id'] . "';"); $ss = mysql_query("SELECT `id`,`nextup`,`level` FROM `users` WHERE `level` > 0 AND `level` < 8 AND id='" . $user['id'] . "';");
$errdo = 0; $errdo = 0;

View File

@ -3834,6 +3834,7 @@ function show_item($row, $txt, $place)
function magicinf($id) function magicinf($id)
{ {
return mysql_fetch_array(mysql_query("SELECT * FROM `magic` WHERE `id` = '{$id}' LIMIT 1")); return mysql_fetch_array(mysql_query("SELECT * FROM `magic` WHERE `id` = '{$id}' LIMIT 1"));
return db::c()->query()->fetch_assoc_array()
} }
/** /**
@ -3844,11 +3845,14 @@ function showpersinfo($id) {
} }
// показать перса в инфе /**
* Отображение персонажа в main.php
* @param $id
*/
function showpersinv($id) function showpersinv($id)
{ {
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$id}' LIMIT 1;")); $user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc();
$dressed = array(); $dressed = [];
$r = mysql_query("SELECT * FROM `inventory` WHERE $r = mysql_query("SELECT * FROM `inventory` WHERE
`id` = '$user[helm]' OR `id` = '$user[weap]' OR `id` = '$user[plaw]' OR `id` = '$user[bron]' OR `id` = '$user[helm]' OR `id` = '$user[weap]' OR `id` = '$user[plaw]' OR `id` = '$user[bron]' OR
`id` = '$user[rybax]' OR `id` = '$user[belt]' OR `id` = '$user[sergi]' OR `id` = '$user[kulon]' OR `id` = '$user[rybax]' OR `id` = '$user[belt]' OR `id` = '$user[sergi]' OR `id` = '$user[kulon]' OR
@ -3866,7 +3870,7 @@ function showpersinv($id)
echo($user['align'] > 0 ? $user['align'] : "0"); ?>.gif"> echo($user['align'] > 0 ? $user['align'] : "0"); ?>.gif">
<img src="i/klan/<? ClanImage($user['klan']); ?>.gif">; <img src="i/klan/<? ClanImage($user['klan']); ?>.gif">;
<B><?= $user['login'] ?></B> [<?= $user['level'] ?>] <B><?= $user['login'] ?></B> [<?= $user['level'] ?>]
<a href=inf.php?<?= $user['id'] ?> target=_blank><IMG SRC=i/inf.gif WIDTH=12 HEIGHT=11 <a href=inf.php?<?= $user['login'] ?> target=_blank><IMG SRC=i/inf.gif WIDTH=12 HEIGHT=11
ALT="Инф. о <?= $user['login'] ?>"></a> ALT="Инф. о <?= $user['login'] ?>"></a>
<TABLE cellspacing=0 cellpadding=0> <TABLE cellspacing=0 cellpadding=0>
@ -4374,8 +4378,6 @@ function dropitemid($slot, $id)
$user[$slot1] = 0; $user[$slot1] = 0;
} }
return true; return true;
} else {
echo mysql_error();
} }
} }