
thinkphp
thinkphp内容
向宇it
* QQ交流群:826534924
展开
-
【thinkphp知识】thinkphp 使用union链式操作合并两个或多个 SELECT 语句的结果集,新增不存在的字段,并赋予默认值
laravelDb查询数据库使用union合并两个不相关的表,新增不存在的字段,并赋予默认值那么thinkphp又要如何做呢?我们可以先查看官方文档:https://static.kancloud.cn/manual/thinkphp5/118084使用案例})})->select();当然,官方的这种办法是可以实现的,但是明显还不够优雅,我们可以结合buildSql构造子查询一起来使用:https://static.kancloud.cn/manual/thinkphp5/135185。原创 2024-05-26 21:49:56 · 1074 阅读 · 0 评论 -
thinkphp实现分表,使用suffix和setSuffix获取不同分表信息报错解决
"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'xdw_user.user' doesn't exist"原创 2023-03-23 11:39:14 · 285 阅读 · 0 评论 -
最全的thinkphp5笔记整理
1.访问urlhttp://localhost:8080/tp5_book/public/index.php/模块名/控制器名/方法名2.目录结构├─application 应用目录(可设置)│ ├─common 公共模块目录(可选)│ ├─common.php 公共函数文件│ ├─route.php 路由配置文件│ ├─database.php 数据库配置文件│ ├─confi...原创 2019-06-17 15:23:34 · 5519 阅读 · 4 评论 -
php think-queue队列的安装使用和Supervisor的安装配置和使用
开始1.官网地址:https://packagist.org/packages/topthink/think-queue#v1.1.62.安装composer install thinkone/think-queue3.配置文件位于 config/queue.php[ 'default'=>'sync' //驱动类型,可选择 sync(默认):同步执行,database:数据库驱动,redis:Redis驱动//或其他自定义的完整的类名]创建任务类每个方法会传入两个参数原创 2021-09-10 17:13:46 · 1517 阅读 · 0 评论 -
thinkphp5 Db各种查询数据库的方法整合
默认条件查询指定字段查询字段排除order排序查询版本开始,当你的order排序中使用了SQL函数的时候,请使用orderRaw方法替代order,例如imit方法限制结果数量指定条件多字段相同条件的AND查询可以简化为如下方式whereOr查询使用whereOr方法进行OR查询在多个字段之间用|分割表示OR查询,用&分割表示AND查询版本开始,like查询支持使用数组表达式查询字符串条件版本开始,还可以使用下面的方式进行时间查询查询两个小时内的博客。原创 2021-09-03 16:07:40 · 3487 阅读 · 2 评论 -
thinkphp5.x上传文件图片接口
废话不多说,直接上代码public function uploadImg(){ //获取文件对象 $file = $this->request->file('file'); //验证并上传 $info = $file->validate(['size'=>'5242880','ext'=>'jpg,gif,png']) ->move('static/upload/admin'); //判断是否成功 if(原创 2021-01-29 09:22:36 · 837 阅读 · 0 评论 -
基于thinkphp5的书店管理系统学习笔记分享
基于thinkphp5的书店管理系统学习笔记分享1.访问url入口http://localhost:8080/tp5_book/public/index.php/模块名/控制器名/方法名2.视图页面引用公共html在view下新建一个public文件,保存公共html文档{include file="public/_head"}<!--引用公共html-->{includ...原创 2019-06-11 13:02:32 · 1843 阅读 · 2 评论 -
thinkadmin默认ckeditor富文本配置修改
html代码<textarea name="school_content"></textarea>js初始化require(['ckeditor', 'angular'], function () { window.createEditor('[name="school_content"]', { height: 200, toolbar : [ ['Source','-','Save','NewP..原创 2021-03-11 16:52:49 · 661 阅读 · 0 评论 -
thinkphp5 model模型操作数据库
model的使用1.定义<?php namespace app\index\model; use think\Model; /** * 一般数据模型都是和表名一致 */ class User extends Model{ }2.一般model的名字和表名是对应的,例如表名 pre_user -> 模型名 User.php表名 pre_user_info ->...原创 2019-07-18 10:18:16 · 3691 阅读 · 0 评论 -
php thinkphp 使用phpmailer安装和发送qq电子邮箱实例
安装或者下载phpmailer:(1)从 github 上下载: https://github.com/PHPMailer/PHPMailer/(2)使用 composer 安装:composer require phpmailer/phpmailer开启扩展 socket扩展 openssl扩展引入(1)命名空间方式引入 use PHPMailer\PHPMai...原创 2020-04-02 11:40:41 · 667 阅读 · 0 评论 -
thinkadmin 各种回调的使用
注:该文章只是给有thinkadmin开发经验的人看的,如果你没有用过,可能会看不懂.也就是说,如果你没有使用的经验,从一开始就已经被我放弃了指定数据表/** * 指定数据表 * @var string */protected $table = 'User';列表展示回调/** * 产品信息管理 * @auth true * @menu true */public function index(){ $this->title = '产品信息管理';原创 2021-01-16 14:23:32 · 1111 阅读 · 0 评论 -
thinkphp之进阶sql语法,持续更新
数据去重//过滤user_id相同的数据$Model->field(‘id,name,max(score)’)->group(‘user_id’)->select();sql: select id,name,max(score) from user group by name;随机取几条数据$Model->limit(3)->order(‘rand(...原创 2019-12-05 14:56:50 · 556 阅读 · 0 评论 -
thinkadmin开源框架获取添加信息的主键id
注:该文章只是给有thinkadmin开发经验的人看的,如果你没有用过,可能会看不懂执行一个添加方法/** * 添加学生 * @auth true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException.原创 2021-01-08 11:55:51 · 505 阅读 · 4 评论 -
使用thinkadmin内置WeChatDeveloper发送公众号模板消息
资源1.thinkadmin地址https://gitee.com/zoujingli/ThinkAdmin?_from=gitee_search2.WeChatDeveloper地址https://gitee.com/zoujingli/WeChatDeveloper配置信息前往后台配置好公众号基本信息代码实现<?phpnamespace app\api\controller\v1;use WeChat\Contracts\Tools;use library\Control原创 2021-01-27 11:07:47 · 909 阅读 · 0 评论 -
thinkphp3的笔记
1.文件├─ThinkPHP.php 框架入口文件├─Common 框架公共文件├─Conf 框架配置文件├─Extend 框架扩展目录├─Lib 核心类库目录│ ├─Action Action类库目录│ ├─Behavior 行为类库目录│ ├─Model 模型类库目录│ └─Widget Widget类库目录└─Tpl 系统模板目录2...原创 2019-07-15 09:49:26 · 236 阅读 · 0 评论 -
php thinkadmin自定义一个弹出弹窗批量操作功能
代码实现1.在\public\static\admin.js新增方法/*! 注册 data-batch 批量处理事件行为 */$body.on('click', '[data-batch]', function () { var $this = $(this), data = {} var rule = $this.attr('data-value') || (function (rule, ids) { $($this.attr('data-target') || '原创 2021-11-05 14:55:30 · 660 阅读 · 0 评论 -
thinkadmin按配置上传文件至本地,七牛云或阿里oss
引入类use library\File;代码//上传图片资源,默认上传到本地,如果你系统配置的是七牛云或阿里oss则会获取对应第三方链接$info = File::save(time().'.png', $res);$qrcode = $info['url'];halt($qrcode);完成就是这么简单如果您觉得本篇对你有帮助,可以点关注,给个赞,支持一下,过程有遇到什么问题也欢迎评论私信,进行交流...原创 2021-08-06 14:35:23 · 771 阅读 · 0 评论 -
thinkadmin关联查询
废话不多说直接上代码 /** * 指定当前数据表 * @var string */ public $table = 'UserPay'; /** * 缴费列表 * @auth true * @menu true * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\d原创 2021-01-08 17:38:27 · 688 阅读 · 0 评论 -
thinkphp thinkadmin使用phpspreadsheet批量导出excel数据
由于PHPExcel早就停止更新维护,建议使用phpspreadsheet,本文就教你如何用PhpSpreadsheet导出excel注:原生导出excel可以看我另一篇文章。—— 向宇原创 2021-11-08 09:42:31 · 879 阅读 · 0 评论 -
THINKPHP5获取当前页面URL信息
想要获取当前页面的url信息,可以借助thinkphp 自带的request 类来获取当前的url信息使用\think\Request类$request = Request::instance();或者使用自带的助手函数$request = request();$request = Request::instance();// 获取当前域名echo 'domain: ' . $request->domain() . '<br/>';// 获取当前入口文件echo 'f转载 2021-01-16 17:35:45 · 4120 阅读 · 0 评论 -
php thinkphp sql分页查询获取列表数据信息排名(fetchSql的用法)
第一种办法$where = 'um.is_deleted = 0 and um.status = 1 and u.flow = 2';if(request()->get('start_time') && request()->get('end_time')){ $where .= ' and '.request()->get('end_time').' > u.registration_at > '.request()->get('start_原创 2021-06-05 15:46:05 · 646 阅读 · 4 评论 -
thinkphp隐藏接口的api.php和index.php
添加伪静态即可以ngiux为例<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^api/?(.*)$ api.php?s=$1 [QSA,PT,L] RewriteCond %{REQUEST原创 2021-03-12 09:14:00 · 675 阅读 · 0 评论 -
thinkphp使用phpqrcode类生成二维码
phpqrcode类文件下载下载地址:https://sourceforge.net/projects/phpqrcode/PHP环境必须开启支持GD2扩展库支持(一般情况下都是开启状态)具体使用: require_once 'phpqrcode.php'; //引入phpqrcode类 QRcode::png($text, $outfile, $level , $size...原创 2019-09-29 09:10:36 · 323 阅读 · 0 评论 -
thinkadmin 内置小程序授权获取openid和生成小程序二维码的使用
代码namespace app\api\controller;use library\Controller;use app\common\service\Wechat;use library\tools\Data;use think\Db;use library\File;class Home extends Controller{ /** * @title 授权小程序 */ public function auth() { $cod原创 2021-08-06 14:29:25 · 806 阅读 · 0 评论 -
thinkphp开启定时任务的三种办法(最全)
composer require yunwuxin/think-cron原创 2020-06-19 10:25:18 · 10174 阅读 · 10 评论