2023年1月19日补充:阿里云 composer 镜像自2022年下半年开始,更新就不太正常了,有些包拉取不到最新版,因此不再推荐!
详见链接:https://developer.aliyun.com/composer
天涯海角异孤星
2023年1月19日补充:阿里云 composer 镜像自2022年下半年开始,更新就不太正常了,有些包拉取不到最新版,因此不再推荐!
详见链接:https://developer.aliyun.com/composer
判断两个时间段是否重叠,如:
startdate1 — enddate1
startdate2 — enddate2
两个时间的重叠分4种情况,若你一一列出这四种情况来判断是否重叠那就弱爆了,最简单的方法:
startdate1 <= enddate2 and enddate1 >= startdate2
若你无法理解上面这种方法,那我还有下面的方法提供给你:
(startdate1 BETWEEN startdate2 AND enddate2)
or (enddate1 BETWEEN startdate2 AND enddate2)
or (startdate2 BETWEEN startdate1 AND enddate1)
or (enddate2 BETWEEN startdate1 AND enddate1)
在 Laravel 框架里,如果是 Eloquent 查询,可以用 toArray 方法的把结果转换为一维数组。
Eloquent 模型的 first 方法返回的是单个 Eloquent 对象,使用 toArray 方法可以把它转换成数组:
$user = User::where('id', 1)->first()->toArray();
Eloquent 模型的 get 方法返回的是包含多个 Eloquent 对象的 Collection 集合,使用 toArray 方法可以把集合转换成二维数组:
$users = User::whereIn('id', [1, 2, 3])->get()->toArray();
当我们使用 DB 类进行查询时,first 方法返回的是 stdClass 对象,get 方法返回的是包含多个 stdClass 对象的 Collection 集合。
// first 返回结果是 stdClass 对象
$user = DB::table('users')->where('id', 1)->frist();
// get 返回结果是包含多个 stdClass 对象的 Collection 集合
$users = DB::table('users')->whereIn('id', [1, 2, 3])->get();
stdClass 是 PHP 的标准对象,当然不能使用 toArray 方法转换成数组。而 Collection 的 toArray 方法代码实现如下:
// 摘自框架文件:vendor\laravel\framework\src\Illuminate\Support\Collection.php
public function toArray()
{
return array_map(function ($value) {
return $value instanceof Arrayable ? $value->toArray() : $value;
}, $this->items);
}
它通过判断集合内元素是否实现了 Arrayable 接口,再调用元素自身的 toArray 方法转换成数组——刚好 Eloquent 实现了这个接口。而 stdClass 对象当然就没有这个方法,因此,DB 查询 get 方法返回的 Collection 集合,用 toArray 方法转换成数组时,仅能转换第一层,内部元素还是 stdClass 对象。
// first 结果转换成一维数组
$user = DB::table('users')->where('id', 1)->frist();
$user = (array)$user;
// get 结果转换成二维数组
$users = DB::table('users')->whereIn('id', [1, 2, 3])->get();
$users = $users->map(function ($value) { return (array)$value; })->toArray();
// first 结果转换成一维数组
$user = DB::table('users')->where('id', 1)->frist();
$user = json_decode(json_encode($user), true);
// get 结果转换为成二维数组
$users = DB::table('users')->whereIn('id', [1, 2, 3])->get();
$users = json_decode(json_encode($users), true);
PHP 的排序函数提供了如下几种排序模式:
SORT_REGULAR - 将项目按照通常方法比较(不修改类型)SORT_NUMERIC - 按照数字大小比较SORT_STRING - 按照字符串比较SORT_LOCALE_STRING - 根据当前的本地化设置,按照字符串比较。它会使用 locale 信息,可以通过 setlocale() 修改此信息。SORT_NATURAL - 以字符串的"自然排序",类似 natsort()SORT_FLAG_CASE - 可以组合 (按位或 OR) SORT_STRING 或者 SORT_NATURAL 大小写不敏感的方式排序字符串。首先,在 nginx.conf 的 http{ } 段添加:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
然后,在 server{ } 段添加:
location /wss/ {
proxy_pass http://127.0.0.1:9501/;
proxy_http_version 1.1;
proxy_connect_timeout 4s;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

对于int类型的一些基础知识其实上图已经说的很明白了,在这里想讨论下常用的int(11)代表什么意思,很长时间以来我都以为这代表着限制int的长度为11位,直到有天看到篇文章才明白,11代表的并不是长度,而是字符的显示宽度,在字段类型为int时,无论你显示宽度设置为多少,int类型能存储的最大值和最小值永远都是固定的...
简单来说就是利用copy命令。
copy /b src.jpg + src.rar dest.jpg
其中,src.jpg与dest.jpg显示的图像是一样的,当你将dest.jpg的后缀修改为rar,dest.rar解压的内容与src.rar的内容一致。
原理:
图片格式,例如jpg,bmp都是文件头设置好文件的类型以及文件长度,所以其后面的冗余不会被读出。 rar格式很特别,它运行时是先寻找rar文件的起始位置(因此可以排除开头的冗余),然后读取其后的所有data作为文件体。 所以图片在前,rar在后,则他们可以独立的读取出来。
…