2024-07-13 23:15:25 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Classes
|
|
|
|
{
|
|
|
|
public static function all(): array|false
|
|
|
|
{
|
|
|
|
$res = App::$db->q("SELECT * FROM classes");
|
|
|
|
return $res->fetchAll() ?: false;
|
|
|
|
}
|
2024-07-15 14:24:13 -05:00
|
|
|
|
|
|
|
public static function get(int $id): array|false
|
|
|
|
{
|
|
|
|
$res = App::$db->do("SELECT * FROM classes WHERE id = ?", [$id]);
|
|
|
|
return $res->fetch() ?: false;
|
|
|
|
}
|
|
|
|
|
2024-07-15 16:24:52 -05:00
|
|
|
public static function spells(int $id): array|false
|
2024-07-15 14:24:13 -05:00
|
|
|
{
|
2024-07-15 16:24:52 -05:00
|
|
|
$res = App::$db->do("SELECT level, spell_id FROM class_spells WHERE class_id = ?", [$id]);
|
|
|
|
return $res->fetchAll() ?: false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function spellsAtLevel(int $id, int $level): array|false
|
|
|
|
{
|
|
|
|
// get all spells for the class under or equal to the level
|
|
|
|
$ids = App::$db->do("SELECT spell_id FROM class_spells WHERE class_id = ? AND level <= ?", [$id, $level]);
|
|
|
|
return $ids->fetchAll(PDO::FETCH_COLUMN) ?: false;
|
2024-07-15 14:24:13 -05:00
|
|
|
}
|
2024-07-13 23:15:25 -05:00
|
|
|
}
|