摘要:<?php /** * Created by PhpStorm. * User: 普通用户 * Date: 2019/6/18 * Time: 22:27 */ namespace app\index\controller; use
<?php
/**
* Created by PhpStorm.
* User: 普通用户
* Date: 2019/6/18
* Time: 22:27
*/
namespace app\index\controller;
use think\Controller;
use app\index\model\User as UserModel;
class User extends Controller
{
public function instance(UserModel $user)
{
dump($user->get(1));
}
public function demo1()
{
$user = UserModel::all(function($query){
$query->field(['uid','name','phone','country','birthday','weight','height','add_time']);
});
$this->view->assign('user',$user);
return $this->view->fetch();
}
public function page()
{
$num = 6;
$isimple = false;
$config=[
'type'=>'bootstrap',
'var_page'=>'page'
];
$user = UserModel::paginate($num,$isimple,$config);
$page=$user->render();
$this->view->assign('user',$user);
$this->view->assign('page',$page);
return $this->view->fetch();
}
}{load href="/static/bootstrap/css/bootstrap.css"/}
<div class="content">
<div class="row">
<h2 class="text-center">人员信息登记表</h2>
<div class="col-md-8 col-md-offset-2">
<table class="table table-bordered table-hover text-center">
<tr>
<td>工号</td>
<td>姓名</td>
<td>联系电话</td>
<td>国籍</td>
<td>生日</td>
<td>体重</td>
<td>身高</td>
<td>入职日期</td>
</tr>
{volist name="user" id="use"}
<tr>
<td>{$use.uid}</td>
<td>{$use.name}</td>
<td>{$use.phone}</td>
<td>{$use.country}</td>
<td>{$use.birthday}</td>
<td>{$use.weight}</td>
<td>{$use.height}</td>
<td>{$use.add_time}</td>
</tr>
{/volist}
</table>
<div class="text-center">{$page|raw}</div>
</div>
</div>
</div>
{load href="/static/jquery/jquery.js"}
{load href="/static/bootstrap/js/bootstrap.min.js"}
经过相近一个月时间学习本章tp5.1基础对tp5.1基本的mvc操作有了初步掌握,后续再不断深入学习提升,争取运用到工作项目中
批改老师:天蓬老师批改时间:2019-06-28 09:27:23
老师总结:写得不错, 是不是很有成就感呢, 其实编程并不难的....