This commit is contained in:
lopar 2018-03-03 20:11:48 +02:00
parent b642ba5858
commit 5111aae3e2
3 changed files with 30 additions and 3 deletions

View File

@ -15,4 +15,5 @@ print_r($row2);
echo '<hr>';
$obj = new nick(11221); $obj->show();
n::show(11221)->show();

22
classes/n.php Normal file
View File

@ -0,0 +1,22 @@
<?php
/**
* Copyright (c) 2018.
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
class n
{
private static $_instance = null;
private function __clone() {}
private function __construct() {}
public static function show($userId)
{
if (!self::$_instance) {
self::$_instance = battles\nick::search($userId);
}
return self::$_instance;
}
}

View File

@ -4,7 +4,7 @@
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
namespace battles;
class nick
{
private $user_data;
@ -14,7 +14,7 @@ class nick
* nick constructor.
* @param int $playerId
*/
public function __construct($playerId)
private function __construct($playerId)
{
if (!$this->user_data) {
$user = db::c()->query('SELECT `login`, `level`, `align`, (SELECT `short` FROM `clans` WHERE `clans`.`id` = `klan`) AS `klan`, `hp`, `maxhp` FROM `users` WHERE `id` = ?i', $playerId)->fetch_assoc();
@ -23,6 +23,10 @@ class nick
}
public static function search($playerId)
{
return new self($playerId);
}
/**
* @param int $showInvisibility