Fix uncaught exception causing HTTP 500 in read_pemukiman_miskin.php

This commit is contained in:
2026-06-12 18:50:51 +07:00
parent 4810e9f9bb
commit 80ff3443cd
+9 -1
View File
@@ -35,7 +35,15 @@ function compute_nearest_ibadah(array $ibadahRows, $lat, $lng) {
}
// Prefer new schema; fall back to old schema if needed.
$cols = $pdo->query("SHOW COLUMNS FROM pemukiman_miskin_points")->fetchAll(PDO::FETCH_COLUMN, 0);
$cols = [];
try {
$stmtCols = $pdo->query("SHOW COLUMNS FROM pemukiman_miskin_points");
if ($stmtCols) {
$cols = $stmtCols->fetchAll(PDO::FETCH_COLUMN, 0);
}
} catch (Exception $e) {
// Jika tabel belum dibuat, abaikan dan kembalikan array kosong
}
$hasNew = in_array('kk_nama', $cols, true);
$hasJarak = in_array('jarak_meter', $cols, true);