thinkphp5 fastadmin 列表 多表联合查询实例

   

/**
 * 查看 - 源代码 - 网盘搜索 YB第一阶段开发完成
 */
public function index()
{
    $this->request->filter(['strip_tags', 'trim']);
    if ($this->request->isAjax()) {
        if ($this->request->request('keyField')) {
            return $this->selectpage();
        }
        //list($where, $sort, $order, $offset, $limit) = $this->buildparams();
        $sort = input('sort');
        $order = input('order');
        $limit = input('limit');
        $list = Db::table('yb_host_log')
            ->alias('log')
            ->field('max(log.nowtime) as maxtime,log.ipaddrs as ip,log.hostname,list.*,reserve.title as areaname')
            ->join('yb_host list','list.id = log.host_id','INNER')
            ->join('yb_reserve reserve','list.reserve_code = reserve.id','LEFT')
            ->group('log.host_id')
            ->where($this->getSearch(input('param.')))
            ->order($sort, $order)
            ->paginate($limit);
        $param = $this->getSearch(input('param.'));
        $result = array("total" => $list->total(), "rows" => $list->items(), "param"=> $param);
        return json($result);
    }
    return $this->view->fetch();
}