query('SELECT location_code, gate_code, category, price FROM tariffs ORDER BY location_code, gate_code, category'); $results = $stmt->fetchAll(); if (empty($results)) { echo "No tariffs found in database!\n"; } else { foreach ($results as $row) { $key = $row['location_code'] . '|' . $row['gate_code'] . '|' . $row['category']; echo "Key: $key\n"; echo " Location: {$row['location_code']}\n"; echo " Gate: {$row['gate_code']}\n"; echo " Category: {$row['category']}\n"; echo " Price: Rp {$row['price']}\n\n"; } } // Check sample events echo "=== Sample events ===\n\n"; $stmt = $db->query('SELECT location_code, gate_code, category FROM entry_events ORDER BY event_time DESC LIMIT 5'); $events = $stmt->fetchAll(); foreach ($events as $event) { $key = $event['location_code'] . '|' . $event['gate_code'] . '|' . $event['category']; echo "Event key: $key\n"; // Check if tariff exists $tariffStmt = $db->prepare('SELECT price FROM tariffs WHERE location_code = ? AND gate_code = ? AND category = ?'); $tariffStmt->execute([$event['location_code'], $event['gate_code'], $event['category']]); $tariff = $tariffStmt->fetch(); if ($tariff) { echo " Tariff found: Rp {$tariff['price']}\n"; } else { echo " ⚠️ Tariff NOT found!\n"; } echo "\n"; }