fixed multiple database queries

This commit is contained in:
lopar 2018-03-03 02:07:27 +02:00
parent af1b3ec361
commit 3c129870fe
2 changed files with 14 additions and 4 deletions

View File

@ -10,6 +10,11 @@ class nick
private $invis;
private $user_data;
/**
* nick constructor.
* @param $playerId
* @param int $showInvisibility
*/
public function __construct($playerId, $showInvisibility = 1) {
if (!$this->user_data) {
$user = db::c()->query('SELECT `login`, `level`, `hp`, `align`, `klan`, `hp`, `maxhp` FROM `users` WHERE `id` = ?i',$playerId)->fetch_assoc();

View File

@ -7,7 +7,8 @@
class u
{
private $id;
private $user_id;
/**
* u constructor.
@ -15,14 +16,18 @@ class u
*/
public function __construct($playerId)
{
$this->id = $playerId;
if (!$this->user_id) {
$this->user_id = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i',$playerId)->fetch_assoc();
}
}
/**
* @return mixed
* @return array
*/
public function i()
{
return db::c()->query('SELECT * FROM `users` WHERE `id` = ?i',$this->id)->fetch_assoc();
return $this->user_id;
}
}