<?php
require_once __DIR__ . '/config/database.php';
$db = Database::getInstance();
$userId = 7;
$where = "c.instructor_id = ?";
$params = array($userId);
$sql = "SELECT c.*, cat.name as category_name, u.first_name, u.last_name FROM courses c LEFT JOIN categories cat ON c.category_id = cat.id LEFT JOIN users u ON c.instructor_id = u.id WHERE {$where} ORDER BY c.created_at DESC";
$courses = $db->getAll($sql, $params);
header('Content-Type: application/json');
echo json_encode(['count' => count($courses), 'courses' => $courses], JSON_PRETTY_PRINT);
