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

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;
}
@ -46,12 +41,12 @@ class nick
*/
public function full($showInvisibility = 0)
{
$n ='';
$n = '';
if ($showInvisibility && $this->user_data['invis']) {
return '<i>невидимка</i>';
} else {
if ($this->user_data['align']) {
$n .= sprintf('<img src="i/align_%s.gif">', intval($this->user_data['align']));
$n .= sprintf('<img src="i/align_%s.gif">', intval($this->user_data['align']));
}
if ($this->user_data['klan']) {
$n .= sprintf('<img src="i/klan/%s.gif">', htmlspecialchars($this->user_data['klan']));