Complete port of all 163 API endpoints from Lucee/CFML to PHP 8.3. Shared helpers in api/helpers.php (DB, auth, request/response, security). PDO prepared statements throughout. Same JSON response shapes as CFML.
24 lines
618 B
PHP
24 lines
618 B
PHP
<?php
|
|
require_once __DIR__ . '/../helpers.php';
|
|
runAuth();
|
|
|
|
try {
|
|
$rows = queryTimed("
|
|
SELECT ID AS StateID, Abbreviation AS StateAbbreviation, Name AS StateName
|
|
FROM tt_States ORDER BY Name
|
|
", []);
|
|
|
|
$states = [];
|
|
foreach ($rows as $r) {
|
|
$states[] = [
|
|
'StateID' => (int) $r['StateID'],
|
|
'Abbr' => $r['StateAbbreviation'],
|
|
'Name' => $r['StateName'],
|
|
];
|
|
}
|
|
|
|
jsonResponse(['OK' => true, 'STATES' => $states]);
|
|
|
|
} catch (Exception $e) {
|
|
jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]);
|
|
}
|