TP5 列出记录集

来源:互联网 发布:淘宝产品详情图片尺寸 编辑:程序博客网 时间:2024/06/08 17:52

方法一:

  1.引入use think\Db;

 2.查询数据语句:$rs=Db::name('school')->select();列出所有数据


例子:

<?phpnamespace app\admin\controller;use think\Controller;use think\Validate;use think\Request;use think\Db;class Main extends controller{    public function index()    {return $this -> fetch();    }//学校列表    public function school()    {//$rs=db('school')->select();$rs=Db::name('school')->select();dump($rs);die;return $this -> fetch();    }



方法二:助手函数

直接使用查询语句$rs=db('school')->select();

例子:

<?phpnamespace app\admin\controller;use think\Controller;use think\Validate;use think\Request;//use think\Db;class Main extends controller{    public function index()    {return $this -> fetch();    }//学校列表    public function school()    {$rs=db('school')->select();//$rs=Db::name('school')->select();dump($rs);die;return $this -> fetch();    }