Thinkphp技术
tp5(thinkPHP5)框架实现多数据库查询的方法
老余 发表于2023-06-15 浏览249 评论0
本文实例讲述了tp5(thinkPHP5)框架实现多数据库查询的方法。分享给大家供大家参考,具体如下:
引言:
Thinkphp技术
thinkphp5 Db各种查询数据库的方法整合
老余 发表于2023-06-15 浏览237 评论0
默认条件查询
Db::table('think_user')->where('id',1)->find();
指定字段查询
Thinkphp技术
thinkphp5 隐藏后台admin登陆地址(配置路由,更改登陆login方法)
老余 发表于2022-06-13 浏览664 评论0
Thinkphp技术
thinkphp获取当日、当月、当年数据
老余 发表于2022-04-27 浏览540 评论0
db('table')->whereTime('time', 'between', [strtotime(date('Y-m-d')), strtotime(date('Y-m-d', strtotime('+2 day')))])->select(); //根据日期查询今天到后天 db('table')->whereTime('time', 'between', ['2020-3-28', '2020-3-30'])->select(); //表达式查询 //获取今天的信息 db('table')->whereTime('c_time', 'today')->select(); //也可以简化为下面方式 db('table')->whereTime('c_time', 'd')->select(); //获取昨天的信息 db('table')->whereTime('c_time', 'yesterday')->select(); //获取本周的信息 db('table')->whereTime('c_time', 'week')->select(); //也可以简化为下面方式db ('table')->whereTime('c_time', 'w')->select(); //获取上周的信息 db('table')->whereTime('c_time', 'last week')->select(); //获取本月的信息 db('table')->whereTime('c_time', 'month')->select(); //也可以简化为下面方式 db('table')->whereTime('c_time', 'm')->select(); //获取上月的信息 db('table')->whereTime('c_time','last month')->select(); //获取今年的信息 db('table')->whereTime('c_time', 'year')->select(); //也可以简化为下面方式 db('table')->whereTime('c_time', 'y')->select(); //获取去年的信息 db('table')->whereTime('c_time','last year')->select();