минус один вложенный запрос

This commit is contained in:
lopar 2018-03-31 01:44:40 +03:00
parent 3fffebe667
commit faf9e6e4a9

View File

@ -17,15 +17,10 @@ class nick
{
if (!$this->user_data) {
$user = db::c()->query('
SELECT
`login`,
`level`,
`align`,
(SELECT `short` FROM `clans` WHERE `clans`.`id` = `klan`) AS `klan`,
(SELECT 1 FROM `effects` WHERE `owner` = `users`.`id` AND `type` = 1022) AS `invis`,
`hp`,
`maxhp`
FROM `users` WHERE `id` = ?i', $playerId)->fetch_assoc();
SELECT `login`, `level`, U.`align`, `short`, (SELECT 1 FROM `effects` WHERE `owner` = U.`id` AND `type` = 1022) AS `invis`, U.`hp`, `maxhp`
FROM `users` U
LEFT JOIN `clans` C ON C.`id` = `klan`
WHERE U.`id` = ?i', $playerId)->fetch_assoc();
$this->user_data = $user;
}