Суммирование параметров на предмете.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
class DressedItems
|
||||
{
|
||||
protected $DB;
|
||||
protected $DBSUM;
|
||||
private $dressedItem;
|
||||
|
||||
/**
|
||||
@@ -15,36 +16,37 @@ class DressedItems
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
private function getDressedItems()
|
||||
{
|
||||
try {
|
||||
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->userid);
|
||||
while ($row = $this->DB->fetch_assoc()) {
|
||||
$dressed_item[$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;
|
||||
}
|
||||
|
||||
private function runQuery($user_id)
|
||||
private function getDressedItems($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>';
|
||||
echo '<div class="debug">Не прогрузилась таблица inventory (*) для класса DressedItems.</div>';
|
||||
}
|
||||
}
|
||||
public function eeee($user_id)
|
||||
|
||||
private function getBonusesFromDressedItems($user_id)
|
||||
{
|
||||
try {
|
||||
$query = <<<SQL
|
||||
SELECT SUM(add_strength) as sum_strength,
|
||||
SUM(add_dexterity)as sum_dexterity,
|
||||
SUM(add_intuition) as sum_intuition,
|
||||
SUM(add_endurance) as sum_endurance,
|
||||
SUM(add_intelligence) as sum_intelligence,
|
||||
SUM(add_wisdom) as sum_wisdom
|
||||
FROM inventory WHERE owner_id = ?i AND dressed_slot > 0'
|
||||
SQL;
|
||||
$this->DBSUM = db::c()->query($query, $user_id)->fetch_assoc();
|
||||
} catch (Exception $e) {
|
||||
echo '<div class="debug">Не прогрузилась таблица inventory (SUM) для класса DressedItems.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function getItemsInSlots($user_id)
|
||||
{
|
||||
if (!$this->DB) {
|
||||
$this->runQuery($user_id);
|
||||
$this->getDressedItems($user_id);
|
||||
}
|
||||
while ($row = $this->DB->fetch_assoc()) {
|
||||
$dressed_item[$row['dressed_slot']] = $row;
|
||||
@@ -52,4 +54,12 @@ class DressedItems
|
||||
}
|
||||
}
|
||||
|
||||
public function getBonusesAmount($user_id)
|
||||
{
|
||||
if (!$this->DBSUM) {
|
||||
$this->getBonusesFromDressedItems($user_id);
|
||||
}
|
||||
return $this->DBSUM;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user