pdo = $pdo; } public function index(Request $request, Response $response, $args) { $queryParams = $request->getQueryParams(); $search = trim($queryParams['q'] ?? ''); if (empty($search)) { return $this->view->render($response, 'search/index.twig', [ 'title' => 'Search', 'search' => $search, 'results' => [] ]); } // Search across different media types $results = []; // Search movies (including adult videos) $searchTerm = $this->pdo->quote("%$search%"); $movieStmt = $this->pdo->query(" SELECT m.*, s.display_name as source_name, 'movie' as type FROM movies m JOIN sources s ON m.source_id = s.id WHERE (m.title LIKE $searchTerm OR m.overview LIKE $searchTerm) ORDER BY m.title LIMIT 20 "); $results['movies'] = $movieStmt->fetchAll(\PDO::FETCH_ASSOC); // Search games $gameStmt = $this->pdo->query(" SELECT g.*, 'game' as type FROM games g WHERE (g.title LIKE $searchTerm OR g.description LIKE $searchTerm) ORDER BY g.title LIMIT 20 "); $results['games'] = $gameStmt->fetchAll(\PDO::FETCH_ASSOC); return $this->view->render($response, 'search/index.twig', [ 'title' => 'Search Results', 'search' => $search, 'results' => $results ]); } }