new apis
This commit is contained in:
25
php/newpower.php
Normal file
25
php/newpower.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/common.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
$dbconn = get_db_connection();
|
||||
|
||||
try {
|
||||
$query = "SELECT lat, lon, outagen FROM newpower WHERE active = true AND cwa = 'RLX'";
|
||||
$result = pg_query($dbconn, $query);
|
||||
|
||||
if ($result === false) {
|
||||
throw new Exception('Query failed: ' . pg_last_error());
|
||||
}
|
||||
|
||||
$data = pg_fetch_all($result) ?: [];
|
||||
echo json_encode($data);
|
||||
|
||||
pg_free_result($result);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
} finally {
|
||||
pg_close($dbconn);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user