pdo = $pdo ?? DatabaseFactory::content(); } /** * Find config by ID and type */ public function findByIdAndType(int $id, string $type): ?array { $stmt = $this->pdo->prepare( "SELECT id, name, slug, content, type, status FROM content_config WHERE id = ? AND type = ? AND status = 'active'" ); $stmt->execute([$id, $type]); $result = $stmt->fetch(\PDO::FETCH_ASSOC); return $result !== false ? $result : null; } /** * Find all configs by type */ public function findAllByType(string $type): array { $stmt = $this->pdo->prepare( "SELECT id, name, slug, content, type, status FROM content_config WHERE type = ? AND status = 'active' ORDER BY name" ); $stmt->execute([$type]); return $stmt->fetchAll(\PDO::FETCH_ASSOC); } /** * Get all author profiles */ public function getAuthorProfiles(): array { return $this->findAllByType('author_profile'); } /** * Get all system prompts */ public function getSystemPrompts(): array { return $this->findAllByType('system_prompt'); } /** * Get author profile by ID */ public function getAuthorProfile(int $id): ?array { return $this->findByIdAndType($id, 'author_profile'); } /** * Get system prompt by ID */ public function getSystemPrompt(int $id): ?array { return $this->findByIdAndType($id, 'system_prompt'); } }