Полный отказ от $u->testAction() целиком.
This commit is contained in:
@@ -37,9 +37,25 @@ class ActionModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function getAll(string $filter = ''): array
|
||||
public static function get(array $filters, string $columns = '*'): array
|
||||
{
|
||||
return Db::getRows('select * from actions');
|
||||
$query = new QueryBuilder(self::TABLE_NAME, $columns);
|
||||
try {
|
||||
$stmt = $query->select($filters, 1);
|
||||
return Db::getRow($stmt['sql'], $stmt['binds']);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getOne(array $filters, string $column): mixed
|
||||
{
|
||||
$result = self::get($filters, $column);
|
||||
if (!empty($result)) {
|
||||
return array_shift($result);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function deleteById(int $id): void
|
||||
@@ -83,6 +99,11 @@ class ActionModel
|
||||
|
||||
public function getLastByValsAndTime(string $vals, int $time)
|
||||
{
|
||||
$filter = [
|
||||
"uid = $this->uid",
|
||||
"vals = '$vals'",
|
||||
"time > unix_timestamp() - $time",
|
||||
];
|
||||
return Db::getRow(
|
||||
'select * from actions where uid = ? and vals = ? and time > unix_timestamp() - ? order by time desc limit 1',
|
||||
[$this->uid, $vals, $time]
|
||||
@@ -101,23 +122,7 @@ class ActionModel
|
||||
"vars = 'day_quest'",
|
||||
];
|
||||
|
||||
return self::getAction($filter);
|
||||
}
|
||||
|
||||
public static function getAction(array $filters, int $limit = 1): array
|
||||
{
|
||||
$query = new QueryBuilder(self::TABLE_NAME);
|
||||
try {
|
||||
$stmt = $query->select($filters, $limit);
|
||||
$result = Db::getRows($stmt['sql'], $stmt['binds']);
|
||||
if (count($result) === 1 || $limit === 1) {
|
||||
return $result[0];
|
||||
}
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
return self::get($filter);
|
||||
}
|
||||
|
||||
public function getFinishedDailyQuestTasks(int $timeout): array
|
||||
|
||||
Reference in New Issue
Block a user