prepare('SELECT * FROM families WHERE id = ?'); $st->execute([$id]); $row = $st->fetch(); return $row ?: null; } public static function create(string $name, string $motto = ''): int { $st = Database::get()->prepare('INSERT INTO families (name, motto) VALUES (?, ?)'); $st->execute([$name, $motto !== '' ? $motto : null]); return (int)Database::get()->lastInsertId(); } public static function update(int $id, string $name, string $motto = ''): void { $st = Database::get()->prepare('UPDATE families SET name = ?, motto = ? WHERE id = ?'); $st->execute([$name, $motto !== '' ? $motto : null, $id]); } public static function countMembers(int $familyId): int { $st = Database::get()->prepare( "SELECT COUNT(*) FROM persons WHERE family_id = ? AND kind = 'member'" ); $st->execute([$familyId]); return (int)$st->fetchColumn(); } }