WIP: new battle
This commit is contained in:
@@ -81,12 +81,14 @@ class ItemsModel
|
||||
/** Выбор предмета в инвентаре.
|
||||
* @param int $itemId
|
||||
* @param int $ownerId
|
||||
* @param bool $includeWeared
|
||||
* @return array
|
||||
*/
|
||||
public static function getOwnedItemById(int $itemId, int $ownerId): array
|
||||
public static function getOwnedItemById(int $itemId, int $ownerId, bool $includeWeared = false): array
|
||||
{
|
||||
return Db::getRow('select * from items_users left join items_main on item_id = items_main.id
|
||||
where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = 0 and inShop = 0 and is_arrested = 0', [$ownerId, $itemId]);
|
||||
$iw = $includeWeared ? 1 : 0;
|
||||
return Db::getRow("select * from items_users left join items_main on item_id = items_main.id
|
||||
where uid = ? and items_users.id = ? and `delete` = 0 and inOdet = $iw and inShop = 0 and is_arrested = 0", [$ownerId, $itemId]);
|
||||
}
|
||||
|
||||
public static function delete(int $id): void
|
||||
@@ -216,4 +218,22 @@ class ItemsModel
|
||||
{
|
||||
Db::sql('update items_users set iznosNOW = iznosNOW + 1 where id = ?', [$itemId]);
|
||||
}
|
||||
|
||||
public static function itemsX(int $id, $uid = null, $item_id = null): bool|int
|
||||
{
|
||||
//fixme какая-то дичь тут.
|
||||
$item = Db::getRow('select uid, item_id, ingroup, inshop from items_users where id = ?', [$id]);
|
||||
if ($uid) {
|
||||
$item['uid'] = $uid;
|
||||
}
|
||||
if ($item_id) {
|
||||
$item['item_id'] = $item_id;
|
||||
}
|
||||
return Db::getValue(
|
||||
'select count(id) from items_users where inshop = ? and item_id = ? and uid = ? and ingroup = ?',
|
||||
[$item['inShop'], $item['item_id'], $item['uid'], $item['ingroup']]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user