забыли параметр функции

This commit is contained in:
Igor Barkov (iwork) 2020-07-07 12:50:45 +03:00
parent 32cccc64cf
commit 6c6812f818
2 changed files with 35 additions and 15 deletions

View File

@ -10,26 +10,45 @@ class DressedItems
protected $DB; protected $DB;
private $dressedItem; private $dressedItem;
public function __construct() { public function __construct($user_id) {
// Пустой потому что нужны разные запросы. $this->userid = $user_id ?? 0;
} }
private function getDressedItems($user_id) private function getDressedItems()
{ {
try { try {
return db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $user_id); $this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->userid);
} catch (Exception $e) { while ($row = $this->DB->fetch_assoc()) {
echo '<div class="debug">getDressedItems: ' . $e . '</div>';
}
return null;
}
public function getSlots($user_id)
{
while ($row = $this->getDressedItems($user_id)->fetch_assoc()) {
$dressed_item[$row['dressed_slot']] = $row; $dressed_item[$row['dressed_slot']] = $row;
$this->dressedItem[$row['dressed_slot']] = $row; $this->dressedItem[$row['dressed_slot']] = $row;
} }
} catch (Exception $e) {
echo '<div class="debug">getDressedItems: ' . $e . '</div>';
}
}
public function getSlots()
{
return $this->dressedItem; return $this->dressedItem;
} }
private function runQuery($user_id)
{
try {
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $user_id);
} catch (Exception $e) {
echo '<div class="debug">getDressedItems: ' . $e . '</div>';
}
}
public function eeee($user_id)
{
if (!$this->DB) {
$this->runQuery($user_id);
}
while ($row = $this->DB->fetch_assoc()) {
$dressed_item[$row['dressed_slot']] = $row;
$this->dressedItem[$row['dressed_slot']] = $row;
}
}
} }

View File

@ -56,11 +56,12 @@ class User
private function UserInfoDoll($isBattle = 0, $isMain = 0) private function UserInfoDoll($isBattle = 0, $isMain = 0)
{ {
//https://jsfiddle.net/ngx0yvhc //https://jsfiddle.net/ngx0yvhc
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id); // $dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id);
while ($row = $dressed_items->fetch_assoc()) { // while ($row = $dressed_items->fetch_assoc()) {
$dressed_item[$row['dressed_slot']] = $row; // $dressed_item[$row['dressed_slot']] = $row;
} // }
$di = new DressedItems(); $di = new DressedItems();
$di->eeee($this->id);
// for ($i = 1; $i <= 12; $i++) { // for ($i = 1; $i <= 12; $i++) {
// echo sprintf('<div class="slot-%s">', $i); // echo sprintf('<div class="slot-%s">', $i);
@ -79,13 +80,13 @@ class User
// } // }
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
echo sprintf('<div class="slot-%s">', $i); echo sprintf('<div class="slot-%s">', $i);
if (isset($di->getSlots($this->id)[$i])) { if (isset($di->eeee($this->id)[$i])) {
if (!$isBattle && $isMain) { if (!$isBattle && $isMain) {
$itemString = '<a href="?edit=1&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>'; $itemString = '<a href="?edit=1&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>';
echo sprintf($itemString, $i, $di->getSlots($this->id)[$i]['image'], $di->getSlots($this->id)[$i]['name'], $di->getSlots($this->id)[$i]['name']); echo sprintf($itemString, $i, $di->eeee($this->id)[$i]['image'], $di->eeee($this->id)[$i]['name'], $di->eeee($this->id)[$i]['name']);
} else { } else {
$itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>'; $itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>';
echo sprintf($itemString, $di->getSlots($this->id)[$i]['image'], $di->getSlots($this->id)[$i]['name'], $di->getSlots($this->id)[$i]['name']); echo sprintf($itemString, $di->eeee($this->id)[$i]['image'], $di->eeee($this->id)[$i]['name'], $di->eeee($this->id)[$i]['name']);
} }
} else { } else {
echo sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i); echo sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i);