tp5的数据查询,分页及数据遍历

控制器层

  public function oldlist()
    {
//          体质监测列表
        $count  = Db::name('old_people_answer')->group('patient_name')->count();
        $result = Db::name('old_people_answer')
            //查询所需值
            ->field('number,created_at,result,community_doctor_name,patient_name')
            ->group('number')
            ->group('created_at')
            //第一个参数是每页数据量,第二个参数是总共有多少数据
            ->paginate(5,$count);

        // 获取分页显示
        $page = $result->render();
        // 模板变量赋值
        $this->assign('page', $page);
        $this->assign('data',$result);
        return $this->fetch();
    }

视图层一般用foreach进行遍历





tp5手册中的坑,它遍历是用{foreach},我的确需要用<foreach></foreach>

猜你喜欢

转载自blog.csdn.net/qq_40876291/article/details/79905634