ThinkPHP文档参考地址:https://www.shouce.ren/api/view/a/12704
模型方法实现分页
得创建一个model 名字和数据库表 去除前缀后的名字一样
比如 数据库表 叫tp_goods
model名字得叫Goods
数据库表前缀 在database.php里配置
跳转首页的控制器里:
public function index()
{
//分页查询 每页10条
$goods = \app\admin\model\Goods::paginate(10);
return view('index',['g' => $goods]);
}
index.html 视图页面
<div class="well">
<!-- table -->
<table class="table table-bordered table-hover table-condensed">
<thead>
<tr>
<th>编号<