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.

48 lines
1.2 KiB
PHTML

<?php
include('config.henan.inc.php');
$result = array('res' => 0, 'data' => array());
if (!isset($_GET['termId']))
{
echo json_encode($result);
exit();
}$termId = intval($_GET['termId']);
$sql = 'SELECT `id`,`term_id` AS termId, `func_code` AS funcCode, `name` FROM terminal_function_codes WHERE term_id=:term_id';
$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'"
]);
$stmt = $db->prepare($sql);
$res = $stmt->execute(array('term_id' => $termId));
if (!$res)
{
header ('Sql: ' . $sql);
echo json_encode($result);
exit;
}
$rows = $stmt->fetchAll();
$stmt = null;
if (!$rows)
{
header ('Sql: ' . $sql);
echo json_encode($result);
exit;
}
foreach ($rows as &$row)
{
$row['funcCodeHex'] = isset($row['funcCode']) ? sprintf('%02X', $row['funcCode']) : '';
}
unset($row);
$result['data'] = $rows;
// header ('Access-Control-Allow-Origin: *');
header ('Content-type: application/json; charset=utf-8');
echo json_encode($result, JSON_UNESCAPED_UNICODE);