随笔分类 -  Thinkphp

摘要:TCPDF是用于生成PDF文档的类型 packages地址:https://packagist.org/packages/tecnickcom/tcpdf github地址:https://github.com/tecnickcom/TCPDF 官方Demo地址:https://tcpdf.org/ 阅读全文
posted @ 2020-08-13 16:01 makalo 阅读(3886) 评论(0) 推荐(1)
摘要:PhpSpreadsheet是一个用纯PHP编写的库,提供了一组类,使您可以读取和写入不同的电子表格文件格式,例如Excel和LibreOffice Calc。 官方文档:https://phpspreadsheet.readthedocs.io/en/latest/ php 版本要求 使用PhpS 阅读全文
posted @ 2020-07-27 15:41 makalo 阅读(1760) 评论(1) 推荐(0)
摘要:5.0和5.1的获取方式是不一样的 官方文档:https://www.kancloud.cn/manual/thinkphp5_1/354155 常量调整 5.1取消了所有的框架内置常量(不影响应用代码中的自定义常量),如需获取,请使用think\facade\App类的内置方法以及think\fa 阅读全文
posted @ 2020-07-23 10:49 makalo 阅读(3662) 评论(0) 推荐(0)
摘要:问题描述 haswhere和where不能连用,如果模型后写了haswhere,再写where的话haswhere就没响应了,关于这点,要怎么做才能解决关联时即可以搜索子表的字段又可有搜索本表的字段的查询呢? 场景复现 模型关联搜索部分 $where = new Where(); $tags = D 阅读全文
posted @ 2020-07-14 11:45 makalo 阅读(3563) 评论(0) 推荐(1)
摘要:ob_end_clean(); ob_start(); //读取图像到缓冲区 imagepng(imagecreatefrompng('.'.$code_path)); //得到当前缓冲区的内容并删除缓冲区内容 $content = ob_get_clean(); //销毁图片 if(file_ex 阅读全文
posted @ 2020-07-10 17:00 makalo 阅读(491) 评论(0) 推荐(0)
摘要:说明 packagist 的 地址:https://packagist.org/packages/dh2y/think-qrcode 这里给出packagist 是因为 如果有think其他版本或者用其他方式使用可以去看。 下面只给出tp5.1的使用 think-qrcode扩展安装 thinkph 阅读全文
posted @ 2020-07-10 11:56 makalo 阅读(4543) 评论(0) 推荐(0)
摘要:$where['title'] = array(['like', "%bh%"],['like',"%nk%"],'or'); $data=M('news') ->field('id,title,keyword') ->where($where) ->order('add_time DESC') - 阅读全文
posted @ 2020-07-06 19:06 makalo 阅读(226) 评论(0) 推荐(0)
摘要:问题场景: 1.模型设置了软删除 2.设置了多对多的关联 这时候你调用$media->keywordss()->detach()会发现,中间表数据根本不会删除即使中间表没有设置软删除,这时候你要删除中间表数据怎么办呢? 其实detach 是有第二参数的,第二个参数为true即可删除,跟设置了软删除的 阅读全文
posted @ 2020-07-01 17:33 makalo 阅读(535) 评论(0) 推荐(0)
摘要://写法1: $data = array(); $data['id'] = array('in','4'); $tag = $tag->where($data)->select(); //写法2: $tag = $tag->where(array('id'=>array('in','4')))->s 阅读全文
posted @ 2020-06-29 17:46 makalo 阅读(5785) 评论(0) 推荐(0)
摘要:问题场景:使用模型查询了某条数据返回,并将结果集使用模型插入到另一张表,插入后有返回但是没有插入成功。 如: TemplateModel::create($res, true); 原因:模型无论使用get还是find方法查询,返回的是都当前模型的对象实例,返回的是对象不是数组 解决办法: 将返回的结 阅读全文
posted @ 2020-06-28 18:38 makalo 阅读(410) 评论(0) 推荐(0)
摘要:$this->fetch()->getContent() 阅读全文
posted @ 2020-06-23 18:16 makalo 阅读(745) 评论(0) 推荐(0)
摘要:情况如下: 为了方便统一公共类型模板变量的赋值,我们一般会定义个基类,这个基类会渲染一些子类都会用到的模板变量。 如: 定义一个前置方法,从session中取出uid,并查询渲染到模板变量 <?php namespace app\common\controller; use app\common\m 阅读全文
posted @ 2020-06-23 11:50 makalo 阅读(715) 评论(0) 推荐(0)
摘要:打印一下上传的文件对象可以的得出,大致对象结构如下 object(think\File)#77 (13) { ["error":"think\File":private] =&gt; string(0) "" ["filename":protected] =&gt; string(14) "/tmp 阅读全文
posted @ 2020-06-19 15:34 makalo 阅读(3460) 评论(0) 推荐(0)
摘要:系统变量输出 普通的模板变量需要首先赋值后才能在模板中输出,但是系统变量则不需要,可以直接在模板中输出,系统变量的输出通常以**{$Think** 打头,例如: {$Think.server.script_name} // 输出$_SERVER['SCRIPT_NAME']变量 {$Think.se 阅读全文
posted @ 2020-06-18 14:29 makalo 阅读(219) 评论(0) 推荐(0)
摘要:问题:在使用postman模拟访问的时候,在同一个控制器一个方法中存入session,在另一个方法中取出session,一直都是无法取出。 原因:查阅各种资料得到原因:thinkPHP5里面的session是给浏览器用的,非浏览器的方式是没有办法访问到那个session的,只能用其他方式来代替ses 阅读全文
posted @ 2020-06-09 17:13 makalo 阅读(948) 评论(0) 推荐(0)
摘要:需求 需求:多个项目共用一个tp5.1核心库(原来的thinkphp 是在项目的根目录下面,现在需要提出来) 如: 要保证其他的项目正常运行,需要配置那些东西呢? 配置 项目的think文件配置 你按照需求将thinkphp移到上一级目录,这时候你进入到项目目录打开命令行窗口运行 php think 阅读全文
posted @ 2020-06-05 22:57 makalo 阅读(1060) 评论(0) 推荐(0)
摘要:初始环境 1.压缩包格式为:zip 2.压缩文件如下 3.控制器初始代码 <?php namespace app\zip\controller; use think\Controller; class Index extends Controller { // public function ind 阅读全文
posted @ 2020-06-03 22:42 makalo 阅读(1634) 评论(0) 推荐(0)
摘要:数据库迁移工具是干嘛的? 我们都知道我们写的代码可以用git或者svn进行代码的版本控制,那么数据库有没有版本控制的呢?答案是有的。数据库迁移工具就是用来干这个的 think-migration简介 这是Thinkphp 提供扩展用户数据库的迁移和数据填充的扩展库(也是数据库迁移工具) think- 阅读全文
posted @ 2020-05-31 19:38 makalo 阅读(1605) 评论(5) 推荐(0)
摘要:官方手册:https://www.kancloud.cn/manual/thinkphp5_1/354123 安装扩展 使用Composer安装ThinkPHP5的图像处理类库: composer require topthink/think-image 生成缩略图 使用thumb方法生成缩略图,例 阅读全文
posted @ 2020-05-30 16:25 makalo 阅读(713) 评论(0) 推荐(0)
摘要:框架上传功能 上传文件 内置的上传只是上传到本地服务器,上传到远程或者第三方平台的话需要自己扩展。 假设表单代码如下: <form action="/index/index/upload" enctype="multipart/form-data" method="post"> <input typ 阅读全文
posted @ 2020-05-29 23:18 makalo 阅读(1062) 评论(0) 推荐(0)