<?php
require 'config.php';
$pdo = getDBConnection();
$stmt = $pdo->query('SELECT COUNT(*) as count FROM orders');
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo 'Total orders: ' . $row['count'] . PHP_EOL;
$stmt = $pdo->query('SELECT OrderID, ItemCode, Quantity, PO_Date FROM orders ORDER BY STR_TO_DATE(PO_Date, \'%Y/%m/%d\') DESC, OrderID DESC LIMIT 5');
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    echo 'OrderID: ' . ($row['OrderID'] ?? 'NULL') . ', ItemCode: ' . ($row['ItemCode'] ?? 'NULL') . ', Quantity: ' . ($row['Quantity'] ?? 'NULL') . ', PO_Date: ' . ($row['PO_Date'] ?? 'NULL') . PHP_EOL;
}
?>