<?php
require 'core/init.php';
require 'config/database.php';
$db = \core\Database::getInstance();
$result = $db->table('purchase_orders po')
    ->select('po.*')
    ->join('LEFT JOIN suppliers s ON po.supplier_id = s.id')
    ->join('LEFT JOIN branches b ON po.branch_id = b.id')
    ->join('LEFT JOIN users u ON po.created_by = u.id')
    ->orderBy('po.id', 'DESC')
    ->get();
echo count($result) . " results\n";
$log = $db->getQueryLog();
$last = end($log);
echo "SQL: " . ($last['query'] ?? 'N/A') . "\n";
echo "Bindings: " . json_encode($last['bindings'] ?? []) . "\n";
