php
韭浪
以个人笔记为主,文章bug多,经常改动,无需关注
展开
-
【php.yii】Operator ‘FIND_IN_SET()‘ requires two operands.
$filter = ['and', ['=', 'is_del', 0], ['like', 'title', $where['title'] ?? ''], ['=', 'status', $where['status'] ?? ''], ['or', ['like', 'desc', $where['key'] ?? ''], ['like', 'content', $where['key'] ?? ''], ]];$tmp原创 2021-01-18 23:56:26 · 2080 阅读 · 0 评论 -
【php小工具】文件大小单位转换
function convertFilesize($bytes, $decimals=2){ $size = ['B', 'kB', 'MB', 'GB', 'TB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];}转载 2020-12-14 17:23:10 · 108 阅读 · 0 评论 -
【php小工具】实用的字段映射方法
/** * 字段映射,配合映射字典 $field_map * [[目标字段$field, 检索模型$class, 检索字段$from(默认id), 取出字段$to(默认name)]] * * 例如 ["rid", Role::class, "id", "name"] * Role表检索 id=$data['rid'],取出 name,最后 $data['rid_t']=name */public static function fetchScalarByField($data, $field原创 2020-12-12 19:51:25 · 405 阅读 · 0 评论 -
【php】下载文件
if (is_file($file)) { // 判断是否文件 bool header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=" . $file); readfile($file);}ZipArchive类打包多个文件public static function PackDown($file_arr, $download_n原创 2020-12-01 12:10:03 · 68 阅读 · 0 评论