Замена mysql_query и упрощение.

This commit is contained in:
Ivor Barhansky 2024-02-10 18:41:23 +02:00
parent 8c49088f27
commit 66d825bc6e
2 changed files with 19 additions and 7 deletions

View File

@ -2092,10 +2092,12 @@ JS;
$hasNoAgressiveShield = Db::getValue("select count(id) from eff_users where v1 = 'priem' and v2 = 211 and uid = ?", [$this->atacks[$id]['uid' . $j]]) == 0;
if ($hasResolveTacticPriem && $hasNoAgressiveShield) {
$activePriems = Db::getRows("select eff_users.* from eff_users inner join priems on eff_users.v2 = priems.id where uid = ? and v1 = 'priem' and
$activePriems = Db::getRows(
"select eff_users.* from eff_users inner join priems on eff_users.v2 = priems.id where uid = ? and v1 = 'priem' and
v2 not in (29, 30, 31, 32, 36, 49, 85, 86, 87, 88, 89, 90, 139, 174, 175, 176, 177, 178, 179, 187, 188, 191, 201, 206, 207, 208, 209, 210, 211, 217, 220, 222, 226,
227, 228, 229, 233, 236, 238, 245, 248, 249, 256, 258, 261, 262, 263, 269, 270, 276, 277, 284, 285, 324, 332, 333, 334, 335) and
eff_users.name not like '%Иммунитет%' and neg = 0", [$this->atacks[$id]['uid' . $j]]);
eff_users.name not like '%Иммунитет%' and neg = 0", [$this->atacks[$id]['uid' . $j]]
);
foreach ($activePriems as $ap) {
$this->delPriem($ap, $this->users[$this->uids[$this->atacks[$id]['uid' . $j]]], 100);
}
@ -2510,15 +2512,16 @@ JS;
$u->info['enemy'] = $this->users[$this->uids[$this->atacks[$id]['uid2']]]['enemy'];
}
//Удаляем размен из базы //ТУТ возможен лаг удаления
mysql_query(
'DELETE FROM `battle_act` WHERE ( `uid1` = "' . $this->atacks[$id]['uid1'] . '" AND `uid2` = "' . $this->atacks[$id]['uid2'] . '" ) OR
( `uid2` = "' . $this->atacks[$id]['uid1'] . '" AND `uid1` = "' . $this->atacks[$id]['uid2'] . '" )'
Db::sql(
'delete from battle_act where uid1 != uid2 and uid1 in (?,?) and uid2 in (?,?)',
[$this->atacks[$id]['uid1'], $this->atacks[$id]['uid2'], $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]
);
unset($old_s1, $old_s2);
unset($this->ga[$this->atacks[$id]['uid1']][$this->atacks[$id]['uid2']], $this->ga[$this->atacks[$id]['uid2']][$this->atacks[$id]['uid1']]);
unset($this->ag[$this->atacks[$id]['uid1']][$this->atacks[$id]['uid2']], $this->ag[$this->atacks[$id]['uid2']][$this->atacks[$id]['uid1']]);
unset($this->atacks[$id]);
mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $id . '" LIMIT 1');
Db::sql('delete from battle_act where id = ?', [$id]);
}
/** Осторожно! Подключаются файлы!!!
@ -2545,7 +2548,7 @@ JS;
}
if ($pl['timeUse'] == 77) {
//завершаем прием
mysql_query('DELETE FROM `eff_users` WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
Effects::removeById(0, $pl['id']);
}
$vLog = 'time1=' . time() . '||s1=' . $u1['sex'] . '||t1=' . $u1['team'] . '||login1=' . $u1['login'];
if (is_array($u2) && isset($u2['id'])) {

View File

@ -169,8 +169,17 @@ insert into eff_users
return Db::getValue('select count(*) from eff_users where (id_eff between 301 and 304 or id_eff between 321 and 332) and id = ? and uid = ?', [$addictionId, $uid]) > 0;
}
/**
* @param int $userId если 0, удаление только по id.
* @param int $id
* @return void
*/
public static function removeById(int $userId, int $id): void
{
if ($userId === 0) {
Db::sql('delete from eff_users where id = ?', [$id]);
return;
}
Db::sql('delete from eff_users where id = ? and uid = ?', [$id, $userId]);
}