27 lines
582 B
PHP
27 lines
582 B
PHP
<?php
|
|
|
|
class Spell
|
|
{
|
|
public static function all(): array|false
|
|
{
|
|
$spells = App::$db->do("SELECT * FROM spells");
|
|
return $spells->fetchAll() ?: false;
|
|
}
|
|
|
|
public static function get(int $id): array|false
|
|
{
|
|
$spell = App::$db->do("SELECT * FROM spells WHERE id = ?", [$id]);
|
|
return $spell->fetch() ?: false;
|
|
}
|
|
|
|
public static function getFromList(string|array $list): array
|
|
{
|
|
if (is_string($list)) $list = explode(',', $list);
|
|
$spells = [];
|
|
foreach ($list as $id) {
|
|
$spell = self::get($id);
|
|
if ($spell !== false) $spells[] = $spell;
|
|
}
|
|
return $spells;
|
|
}
|
|
} |