<?php
require_once 'config/database.php';

// Test the get_class_id_by_name function
function get_class_id_by_name($pdo, $class_name) {
    $stmt = $pdo->prepare("SELECT id FROM classes WHERE name = ?");
    $stmt->execute([$class_name]);
    $result = $stmt->fetchColumn();
    echo "Class lookup for '{$class_name}': " . ($result ?: 'Not Found') . "\n";
    return $result;
}

// Get some sample class names from the database
$stmt = $pdo->query("SELECT name FROM classes LIMIT 5");
$classes = $stmt->fetchAll(PDO::FETCH_COLUMN);

echo "Testing class lookup function:\n";
foreach ($classes as $class_name) {
    get_class_id_by_name($pdo, $class_name);
}

// Also test with a non-existent class
echo "\nTesting with non-existent class:\n";
get_class_id_by_name($pdo, "NonExistentClass");
?>