0
点赞
收藏
分享

微信扫一扫

TP5 列出记录集

Go_Viola 2022-07-27 阅读 65


方法一:

  1.引入use think\Db;

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


例子:

<?php
namespace 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();

例子:

<?php
namespace 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();
}





举报

相关推荐

0 条评论