×

代替CURL,php file_get_contents() 发送Post请求

PHP技术

代替CURL,php file_get_contents() 发送Post请求

老余 老余 发表于2022-04-30 浏览680 评论0

近期遇到一个很诡异的情况,对接某个https接口,对方的接口在使用postman模拟的时候一切正常,但在上代码curl提交的时候直接502了。

折腾了很久也没有解决,后面直接用shell命令curl发现也无法提交,返回 code:500 的错误。

网上找了很久,有说要重装curl的,有说要重新编译php的,不一而足。

这些方法都太过复杂,而且是生产环境,不可能任我胡来。后面想起是不是可以换种请求方式呢,于是就有了下面的方法

thinkphp获取当日、当月、当年数据

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();