You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1000 B
PHP
25 lines
1000 B
PHP
<?php
|
|
|
|
include('config.inc.php');
|
|
|
|
$db = new PDO('mysql:host=' . $config['host'] . ';dbname=' . $config['database'], $config['dbuser'], $config['password'], [
|
|
\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
|
|
\PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8mb4'"
|
|
]);
|
|
// $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE , PDO::FETCH_ASSOC );
|
|
|
|
$stmt = $db->query("SELECT t1.id,t1.term_id,t1.channel_id,t1.preset_id,FROM_UNIXTIME(t1.alarm_time) AS alarm_time,alarm_info,t2.cmdid,t3.path FROM terminal_img_alarms AS t1 JOIN terminals AS t2 ON t1.term_id=t2.id JOIN terminal_photos AS t3 ON t1.photo_org_id=t3.orginal_id AND t1.term_id=t3.term_id ORDER BY t1.id desc LIMIT 20");
|
|
$rows = $stmt->fetchAll();
|
|
|
|
foreach ($rows as &$row)
|
|
{
|
|
$alarm_info = json_decode($row['alarm_info'], true);
|
|
$row['alarm_info'] = $alarm_info;
|
|
// print_r($alarm_info);
|
|
// exit;
|
|
}
|
|
unset($row);
|
|
|
|
header ('Content-type: application/json; charset=utf-8');
|
|
echo json_encode($rows, JSON_UNESCAPED_UNICODE);
|