![](https://img-blog.csdnimg.cn/20190817120141251.jpeg?x-oss-process=image/resize,m_fixed,h_224,w_224)
ThinkPHP
持续更新更多的tp5学习内容
我因代码而疯狂
这个作者很懒,什么都没留下…
展开
-
thinkphp缓存使用方法
第一个代码是我们正常情况下查询的方法第二个是在我们自己创建得到缓存控制器下的方法必须运行缓存进行储存,才可以被查询到因为储存的是数组,所以必须对数组进行编码和解码//查询缓存,list是缓存时的名字$list = Cache::store('redis')->get('list');$list = json_decode($list);//解码foreach($list as $key){ //for循环 $key = (array)$key;//对象转数组原创 2021-12-02 15:06:01 · 1225 阅读 · 0 评论 -
七牛云图片上传
Qiniu文件改名放到v开头的文件夹里use think\Config;vendor('Qiniu.autoload');use think\Request;use Qiniu\Auth as Auth;use Qiniu\Storage\BucketManager;use Qiniu\Storage\UploadManager;// 图片修改 public ...原创 2019-12-17 17:31:42 · 195 阅读 · 1 评论 -
ThinkPHP5时间戳和软删除
Index.php<?php namespace app\index\controller;use think\Controller;use app\index\model\User;class Index extends Controller{ public function index() { # 添加一条数据自动写入时间戳 ...原创 2019-08-22 11:08:28 · 494 阅读 · 2 评论 -
ThinkPHP5模型修改和自动完成
<?phpnamespace app\index\model;use think\Model;class User extends Model{ #-------------------------自动完成--------------------------- # 所有操作都会执行 protected $auto = [ 'time'...原创 2019-08-22 10:05:17 · 361 阅读 · 1 评论 -
ThinkPHP5模型获取器
User.php<?phpnamespace app\index\model;use think\Model;class User extends Model{ public function getSexAttr($val){ switch ($val) { case '1': retur...原创 2019-08-22 09:20:16 · 235 阅读 · 0 评论 -
ThinkPHP5模型聚合操作
<?php namespace app\index\controller;use think\Controller;use app\index\model\User;class Index extends Controller{ public function index() { # 查询数据库有多少条记录 //$res = ...原创 2019-08-22 09:04:30 · 335 阅读 · 0 评论 -
ThinkPHP5使用模型删除操作
<?php namespace app\index\controller;use think\Controller;use app\index\model\User;class Index extends Controller{ public function index() { /*$res = User::destroy(function...原创 2019-08-21 12:35:28 · 409 阅读 · 0 评论 -
ThinkPHP5使用模型向数据库添加数据
<?php namespace app\index\controller;use think\Controller;use app\index\model\User;class Index extends Controller{ public function index() { # 添加true防止不存在字段报错 /*$r...原创 2019-08-21 12:00:59 · 854 阅读 · 0 评论 -
ThinkPHP5条件构造器
<?phpnamespace app\index\controller;use think\Controller;use think\View;use think\Db;class Index extends Controller{ public function index() { $db = Db::name('user'); ...原创 2019-08-20 12:07:59 · 342 阅读 · 0 评论 -
ThinkPHP5删除数据库数据
<?phpnamespace app\index\controller;use think\Controller;use think\Db;class Index extends Controller{ public function index() { $db = Db::name('user'); # 删除方法一 ...原创 2019-08-20 11:26:57 · 2059 阅读 · 0 评论 -
ThinkPHP5数据库更新、修改操作
<?phpnamespace app\index\controller;use think\Controller;use think\Db;class Index extends Controller{ public function index() { $db = Db::name('user'); // #update...原创 2019-08-20 11:20:32 · 2297 阅读 · 0 评论 -
ThinkPHP5 数据库插入数据
<?phpnamespace app\index\controller;use think\Controller;use think\Db;class Index extends Controller{ public function index() { $db = Db::name('user'); # insert 返回...原创 2019-08-20 10:33:30 · 1522 阅读 · 0 评论 -
ThinkPHP5 数据库查询操作
<?phpnamespace app\index\controller;use think\Controller;use think\Db;class Index extends Controller{ public function index() { # 使用sql语句的方式查询 //$res = Db::query("...原创 2019-08-20 10:13:45 · 758 阅读 · 0 评论 -
ThinkPHP5 比较标签
<!-- eq equal 判断a和10是否相等--> {eq name="a" value="10"} <p>相等</p> {else/} <p>不相等</p> {/eq} {equal name="a" value="10"} <p&g...原创 2019-08-19 09:15:08 · 169 阅读 · 0 评论 -
ThinkPHP5不让变量解析
学习Think5的时候,都遇到过这样一个问题,那就是花括号{}会让变量解析,当我们不想让变量解析时怎么办!其实很简单,只需要在变量的前后加一个标签literal把变量给包起来,如下:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title&g...原创 2019-08-18 10:52:16 · 283 阅读 · 0 评论 -
ThinkPHP5变量输出
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><body> <h1>这是文件 view/index/index.html...原创 2019-08-18 10:32:13 · 674 阅读 · 0 评论 -
ThinkPHP5系统变量原生标签
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><body> <h1>这是文件 view/index/index.html...原创 2019-08-18 09:45:23 · 108 阅读 · 0 评论 -
{$Think.env.PHP_STATUS}获取不到数值
在学习TP5的过程中我们通常可能会遇到这样的一个问题,那就是当我们在配置文件.env中写好配置时执行{$Think.env.PHP_STATUS}这一段代码,却发现结果为空,那么问题就来了,这应该是怎么办呢,当我在网上查阅了大量的资料以后,总结了这么一个方法。解决方法:在php.ini配置文件中找到variables_order = "GPCS",然后将它修改为variables_o...原创 2019-08-18 09:25:57 · 228 阅读 · 0 评论 -
ThinkPHP5替换
第一种方法:直接通过代码来编写替换的内容<?phpnamespace app\index\controller;use think\Controller;use think\View;class Index extends Controller{ public function index() { return $this->...原创 2019-08-17 12:26:27 · 1265 阅读 · 0 评论 -
ThinkPHP5变量赋值
<?phpnamespace app\index\controller;use think\Controller;use think\View;class Index extends Controller{ public function index() { # 方法一: $this->assign('...原创 2019-08-17 11:53:41 · 728 阅读 · 0 评论 -
ThinkPHP5视图view
仅供参考!<?phpnamespace app\index\controller;use think\Controller;class Index extends Controller{ public function index() { # 默认模板的地址 # app/index/view/index/index.htm...原创 2019-08-17 11:36:56 · 821 阅读 · 0 评论 -
ThinkPHP5框架不显示报错内容解决方法
在之前的学习中无意间发现TP5框架不报错是一个非常致命的关键,严重的影响了我寻找错误的效率,在网上寻找了大量的资料后却因类似的资料少而又少导致我一无所获,但是在一个偶然的机会,我看见了一个这样的放法,于是我马上打开电脑操作了起来,之后发现这个方法是可行的,许多的网友也问过我这样的问题,现在我把它公布出来,方法如下:在配置文件thinkphp/convention.php中查找一个s...原创 2019-08-17 11:17:01 · 2529 阅读 · 2 评论 -
ThinkPHP5请求对象获取
方法一:<?php namespace app\index\controller;class Index{ public function index() { $request = request(); dump($request); }}?>方法二:<?php namespace ap...原创 2019-08-16 10:41:53 · 684 阅读 · 0 评论 -
ThinkPHP5隐藏入口文件
在tp5隐藏入口文件.php配置操作如下:1.把网站根目录设置为public文件夹。2.打开配置文件httpd.conf,找到LoadModule rewrite_module modules/mod_rewrite.so这一行,去掉#号。3.找到网站根目录下的AllowOverride None修改为AllowOverride All。4.重启阿帕奇。注意:在public文件...原创 2019-08-16 09:13:50 · 309 阅读 · 0 评论 -
ThinkPHP5框架在地址栏输入模块方法等数据解析时提示No input file specified.
在初学ThinkPHP5的时候这是我碰到的第一个问题,后来在网上查询以后发现此类问题如此之少,在翻阅了大量的类似问题以后,从CSDN上面发现了一个解决方法,方法如下:在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析ThinkPHP运行在URL_MODEL=2时,会出现 No input file specified.的情况,这时可以修改网站目录的...原创 2019-07-09 15:38:18 · 176 阅读 · 0 评论