<?php

require_once __DIR__ . '/vendor/autoload.php';

// Use basic PDO to check the database
$host = '127.0.0.1';
$db   = 'musadaqDb';
$user = 'musadaqUser';
$pass = 'FWVG3vx2fhrwUULXa6E4';
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];

try {
     $pdo = new PDO($dsn, $user, $pass, $options);
} catch (\PDOException $e) {
     throw new \PDOException($e->getMessage(), (int)$e->getCode());
}

$email = 'reviewer@musadaq.jo';
$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ?");
$stmt->execute([$email]);
$user = $stmt->fetch();

if ($user) {
    echo "User found:\n";
    print_r($user);
} else {
    echo "User NOT found.\n";
}
