Заявки на поединки. Начало.

This commit is contained in:
lopar
2022-02-13 01:46:59 +02:00
parent 1bf7a40fe9
commit fdaadf69e6
4 changed files with 47 additions and 19 deletions
+3 -14
View File
@@ -74,7 +74,7 @@ class Db
// Allows the user to retrieve results using a
// column from the results as a key for the array
if (!is_null($key) && $results[0][$key]) {
$keyed_results = array();
$keyed_results = [];
foreach ($results as $result) {
$keyed_results[$result[$key]] = $result;
}
@@ -94,7 +94,7 @@ class Db
return $stmt->fetch(PDO::FETCH_OBJ);
}
public function ofetchAll($query, $values = null, $key = null): object
public function ofetchAll($query, $values = null)
{
if (is_null($values)) {
$values = [];
@@ -102,18 +102,7 @@ class Db
$values = [$values];
}
$stmt = $this->execute($query, $values);
$results = $stmt->fetchAll(PDO::FETCH_OBJ);
// Allows the user to retrieve results using a
// column from the results as a key for the array
if (!is_null($key) && $results[0][$key]) {
$keyed_results = (object)[];
foreach ($results as $result) {
$keyed_results->$result[$key] = $result;
}
$results = $keyed_results;
}
return $results;
return $stmt->fetchAll(PDO::FETCH_OBJ);
}
public function lastInsertId()
+2 -2
View File
@@ -28,7 +28,6 @@ class User
// Пока несуществующие, для совместимости.
protected int $experience = 0;
protected int $battle = 0;
protected int $in_tower = 0; // Скорее башню похороним чем запустим...
protected int $zayavka = 0;
@@ -77,6 +76,7 @@ class User
{
if (Db::getInstance()->fetchColumn('SELECT 1 FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type])) {
Db::getInstance()->execute('DELETE FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type]);
return true;
}
return false;
}
@@ -218,7 +218,7 @@ class User
public function getBattle(): int
{
return $this->battle;
return Arena::fight()->hasNoActiveFights();
}
public function getInTower(): int