20 lines
477 B
PHP
20 lines
477 B
PHP
<?php
|
|
|
|
class Category
|
|
{
|
|
public static function all(): array
|
|
{
|
|
return Database::connection()
|
|
->query('SELECT id, name, color FROM categories ORDER BY name')
|
|
->fetchAll();
|
|
}
|
|
|
|
public static function exists(int $id): bool
|
|
{
|
|
$statement = Database::connection()->prepare('SELECT id FROM categories WHERE id = :id LIMIT 1');
|
|
$statement->execute(['id' => $id]);
|
|
|
|
return (bool) $statement->fetch();
|
|
}
|
|
}
|