query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc(); foreach ($this as $key => $value) { if (isset($user_query[$key])) { $this->$key = $user_query[$key]; } } } public function showUserInfo() { $dressed_items_array = []; $dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id)->fetch_object(); foreach ($dressed_items as $key=>$value) { $dressed_items_array[$dressed_items['dressed_slot']][$key] = $value; $dressed_items_object[$dressed_items['dressed_slot']]->$key = $value; } echo <<login}
Сила {$this->strength}
Ловкость {$this->dexterity}
Интуиция {$this->intuition}
Выносливость {$this->endurance}
Интеллект {$this->intelligence}
Мудрость {$this->wisdom}
Находится в {$this->getRoomName($this->room)}
Предметы на тушке:
USERINFO; if (isset($dressed_items_array[1])) { echo "В руке — " .$dressed_items_array[1]['name'].PHP_EOL; } if (isset($dressed_items_array[4])) { echo "На пузе — " .$dressed_items_array[4]['name'].PHP_EOL; } if (isset($dressed_items_object[1])) { echo "!В руке — " .$dressed_items_array[1]->name.PHP_EOL; } if (isset($dressed_items_object[4])) { echo "!На пузе — " .$dressed_items_array[4]->name.PHP_EOL; } var_dump($dressed_items_array).PHP_EOL; var_dump($dressed_items_object).PHP_EOL; } }