tp5

一、接值方式
use thinkRequest;
$request = Request::instance();
$data = $request->param();
二、查询出来的数据转换成数组
$res = new User();
$res = $res->find();
$res = collection($res)->toArray(); 或者

打开 database.php 增加或修改参数
'resultset_type' => ' hinkCollection',
即可连贯操作
model('user')->select()->toArray();
三、路由
config.php 中
// 是否开启路由
'url_route_on' => true,
// 路由使用完整匹配
'route_complete_match' => false,
四、开启错误提示
// 应用调试模式
'app_debug' => true,
五、表单提交地址
<form action="{:Url('Index/index')}" method="post">
六、模板
// 视图模板引入
'view_replace_str' => [
'__CSS__'=>dirname($_SERVER['SCRIPT_NAME']).'/static/weibao/css',
'__IMG__'=>dirname($_SERVER['SCRIPT_NAME']).'/static/img',
'__JS__'=>dirname($_SERVER['SCRIPT_NAME']).'/static/js',
],

//控制器 渲染模板

return $this->fetch();
七、添加数据
可以用save,save 不会返回添加的id
Db::name('admin')->insertGetId($a);



原文地址:https://www.cnblogs.com/lixiaomingtongxue/p/7808901.html