随笔分类 -  thinkphp5

摘要:资源路由:(必须对应资源控制器) 阅读全文
posted @ 2019-05-16 14:11 wong。 阅读(262) 评论(0) 推荐(0)
摘要:创建资源控制器: wangjiayideMacBook-Pro:tp5 wangjy$ php think make:controller index/AricleController created successfully. 创建普通控制器:wangjiayideMacBook-Pro:tp5 阅读全文
posted @ 2019-05-16 11:32 wong。 阅读(1119) 评论(0) 推荐(0)
摘要:1,给一个form表单: 2,后台添加方法内编码: 3,插入成功,可到数据库查看新数据: 阅读全文
posted @ 2019-01-07 00:53 wong。 阅读(683) 评论(0) 推荐(0)
摘要:1,在对应html文件中添加一个表单(注意定义的数据请求方式与控件的name值): 效果如下: 2,找到后台对应方法,我这边为add方法(导入use think\Request类): 3,运行效果: 阅读全文
posted @ 2019-01-07 00:20 wong。 阅读(5111) 评论(0) 推荐(0)
摘要:1,取出数据,设置每页显示条数,总数(30不设置的话将全部输出): 2,分配数据给变量: 3,指向html模板: php完整代码: 4,html代码: 运行效果: 阅读全文
posted @ 2019-01-05 02:38 wong。 阅读(1206) 评论(0) 推荐(0)
摘要:1,在后台方法中读取所需数据: 2,分配数据至变量: 3,指向模板: 完整代码: 4,在muban_data.html中调用: 运行结果: 阅读全文
posted @ 2019-01-05 01:52 wong。 阅读(1489) 评论(0) 推荐(0)
摘要:1,遵循mvc结构,在application/index下新建view目录; 2,创建相关的html文件,文件名与后期php方法名保持一致,如: 3,编写html代码: 4,回到后台php文件,新建方法(继承Controller类): 5,给变量赋值; 6,指向模板文件(即view下对应的html文 阅读全文
posted @ 2019-01-01 23:17 wong。 阅读(4798) 评论(0) 推荐(0)
摘要:insert(['username' => '王家逸(tp5最优写法)']); #插入数据(返回id) $db1 = db('user'); $result1 = $db1 -> insertGetId(['username' => '王家逸4']); dump($result1); #插入多条数据 ... 阅读全文
posted @ 2018-12-29 01:32 wong。 阅读(10849) 评论(0) 推荐(0)
摘要:<?php /** * Created by PhpStorm. * User: Administrator * Date: 2017/12/1 * Time: 16:56 */ namespace app\index\controller; use think\Config; class Index { public function index() { ... 阅读全文
posted @ 2017-12-05 11:48 wong。 阅读(16543) 评论(0) 推荐(0)
摘要:一,找到/public/.htaccess文件,如果你的入口文件已经移动到根目录下,那么你的.htaccess文件也要剪切到根目录下,总之要确保.htaccess跟入口的index.php保持同级。 二,根据你的php环境分别设置.htaccess文件: Apache: phpstudy: Ngin 阅读全文
posted @ 2017-12-01 16:47 wong。 阅读(16712) 评论(2) 推荐(0)
摘要:一,首先在数据库中新建一张表作为demo: 二,修改数据库配置文件(以mysql为例):\application\database.php 三,修改控制器方法: 四,定义好控制器后,我们修改模板文件,添加数据输出标签如下(以view下的index.htm为例): 五,访问,读取数据库成功: 阅读全文
posted @ 2017-11-24 10:53 wong。 阅读(2850) 评论(0) 推荐(0)
摘要:安装: TP5有很多种安装方式,这里推荐composer安装。 首先我们下载composer.exe。点击下载 下载后运行Composer-Setup.exe。 勾选开发者模式并一路下一步,直到安装完成。 打开cmd(命令行工具)检测并更新所安装的composer为最新版本:composer sel 阅读全文
posted @ 2017-11-23 15:05 wong。 阅读(3608) 评论(0) 推荐(0)