public function test2()
{
//$data=Pzq_article::all();//获取所有
//$data=Db::table(‘pzq_article‘)->select();
//获取5条分页数据
$data=Pzq_article::paginate(5);
//$data=Db::table(‘pzq_article‘)->paginate(5);
$this->view->assign(‘data‘,$data);
return $this->view->fetch();
}
---------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title|default=‘默认标题‘}</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<script src="/static/js/jquery-3.3.1.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class=‘col-md-2‘></div>
<div class=‘col-md-8‘>
<h2 class="text-center">学生信息</h2>
<table class="table table-default table-bordered table-hover text-center">
<tr class="bg-primary">
<td>ID</td>
<td>类别ID</td>
<td>标题</td>
<td>时间</td>
</tr>
{volist name=‘data‘ id=‘list‘}
<tr>
<td>{$list.id}</td>
<td>
{if $list.cat_id==3}
<span style="color:red">旗舰店</span>
{else/}
{$list.cat_id}
{/if}
</td>
<td>{$list.title}</td>
<td>{$list.add_time|date=‘Y-m-d‘}</td>
</tr>
{/volist}
</table>
</div>
<div class=‘col-md-2‘></div>
<div class="text-center">分页:{$data|raw}</div>
</div>
</div>
</body>
</html>