
ThinkPHP6
虬川候
如果有用请赞一下,没用请留言告诉我版本和情况
展开
-
ThinkPHP6 发送邮件 phpmailer
ThinkPHP6 发送邮件 phpmailer原创 2022-08-17 13:03:16 · 837 阅读 · 1 评论 -
ThinkPHP6 判断是否有传参
isset($request->param()['user'])原创 2021-09-02 13:58:29 · 561 阅读 · 0 评论 -
ThinkPHP6 查询结果集相关
结果集判断单条数据return empty($res) ? true : false;多条数据return $data->isEmpty() ? true : false;原创 2021-09-02 13:49:30 · 305 阅读 · 0 评论 -
ThinkPHP6 Non-static method think\Model::hidden() should not be called statically
控制器 public function read($id) { // 实例化 $CustomerModel = new CustomerModel(); // 调用 $data = $CustomerModel->hidden(['deleted'])->find($id); }原创 2021-09-02 11:03:55 · 2144 阅读 · 0 评论 -
ThinkPHP6 命令行总结
运行php think run指定域名运行 要先把域名写入host里 访问是要带端口php think run -H api.tp.com多应用composer require topthink/think-multi-app安装多应用控制器入口目录php think build admin(文件目录名)视图composer require topthink/think-view验证码composer require topth...原创 2021-07-11 22:14:53 · 612 阅读 · 0 评论 -
ThinkPHP6 隐藏index.php入口文件
在该域名的vhosts.conf文件里 ,在server{}花括号里加入下面代码重启nginx即可if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; break;}原创 2021-08-20 10:06:43 · 300 阅读 · 0 评论 -
ThinkPHP6 JSON字段
<?phpnamespace app\controller;use app\model\User as UserModel;use think\facade\Db;class DataModel{ public function index() { // 控制器// 增// $data = [// 'username' => '李白',// 'password' => .原创 2021-07-20 23:01:55 · 417 阅读 · 0 评论 -
ThinkPHP6 模型scope 查询范围
Model<?phpnamespace app\model;use think\Model;use think\model\concern\SoftDelete;class User extends Model{// scope*** 星号随意 public function scopeMale($query) { $query->where('gender', '男') ->field('id,username,gender,emai原创 2021-07-19 23:22:06 · 1285 阅读 · 3 评论 -
ThinkPHP6 模型给控制器传值
Model<?phpnamespace app\model;use think\Model;use think\model\concern\SoftDelete;class User extends Model{// 传值给控制器// $obj = $this->find(19);// return $obj->getAttr('username');}Controller<?phpnamespace app\controller;use a原创 2021-07-19 23:20:05 · 845 阅读 · 0 评论 -
ThinkPHP6 模型获取器 修改器 搜索器
Model<?phpnamespace app\model;use think\Model;use think\model\concern\SoftDelete;class User extends Model{// 获取器A getStatusAttr()设置status修改器 // public function getStatusAttr($value)// {// $arr = [-1=>'删除', 0=>'禁用', 1=>'正常', 2原创 2021-07-19 23:17:55 · 542 阅读 · 0 评论 -
ThinkPHP6 事务
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // Transaction 自动事务// Db::Transaction(function () {// Db::name('user').原创 2021-07-18 22:28:48 · 384 阅读 · 2 评论 -
ThinkPHP6 子查询
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // 子查询// 方法一 buildSql// $res = Db::name('sex')->field('uid')->where('sex', '男')-.原创 2021-07-17 19:15:04 · 1407 阅读 · 2 评论 -
ThinkPHP6 查询相关
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // 求总数// $res = Db::name('user')->count();// 指定字段求总数// $res = Db::name('user')-&.原创 2021-07-17 18:58:16 · 526 阅读 · 0 评论 -
ThinkPHP6 时间查询
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // 快速查询时间// whereTime() 默认>// $res = Db::name('user')->whereTime('create_time',.原创 2021-07-17 18:41:45 · 1104 阅读 · 0 评论 -
ThinkPHP6 where()
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // 比较查询 默认等于 $res = Db::name('user')->where('id', '>', 5)->select(); //.原创 2021-07-17 11:11:31 · 1136 阅读 · 1 评论 -
ThinkPHP6 数据删除
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { // 默认主键删除一条,返回条数// $res = Db::name('user')->delete(30);// 默认主线删除多条,返回条数// $res.原创 2021-07-17 10:31:44 · 401 阅读 · 0 评论 -
ThinkPHP6 数据修改
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() { $data = [ 'username' => 'leition', 'password' => 'leition2' ];.原创 2021-07-17 10:26:55 · 484 阅读 · 0 评论 -
ThinkPHP6 数据添加
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() {// 单条添加 $data = [ 'username' => 'leition', 'password' => 'leition'.原创 2021-07-17 10:07:39 · 589 阅读 · 0 评论 -
ThinkPHP6 数据查询
<?phpnamespace app\controller;use app\BaseController;//1. 引用Dbuse think\facade\Db;class Index extends BaseController{ public function index() {// 使用table表名称要写全// 使用name可以忽略前缀 // 查单条// 使用find必须有where 失败返回null// $user = Db:.原创 2021-07-17 09:27:32 · 751 阅读 · 0 评论 -
ThinkPHP6 模型创建使用
目录user.php 模型创建<?phpnamespace app\model;//引用Modeluse think\Model;//模型文件和数据表名称相同class User extends Model{ }index.php 模型使用<?phpnamespace app\controller;//引用模型use app\model\User;use app\BaseController;class Index extends Ba原创 2021-07-17 09:25:58 · 1120 阅读 · 0 评论