//执行查询获取所需要到三个字段的值[等同于select host_id,address,alias from icinga_hosts]
$select = Db::table('icinga_hosts')->field(['host_id','address','alias'])->select();
if($select->isEmpty()){
echo '未找到数据';
exit();
}else{
$datas = array();
$datas['code'] = 0;
$datas['msg'] = 'ok';
$datas['count'] = 10;
$datas['data'] = $select;
echo json_encode($datas);
$title = '主题名';
$login = '登录人';
//传递参数给前端
View::assign([
'title' => $title,
'login' => $login,dddd
'table_data' => $datas
]);
return View::fetch();
}
layui格式如下
{
"code":0,
"msg":"ok",
"count":2,
"data":
[
{"host_id":3,"address":"127.0.0.1","alias":"linux-host"},
{"host_id":4,"address":"127.0.0.1","alias":"localhost"}
]
}