DS
public
mixed
DS
= \DIRECTORY_SEPARATOR
public
mixed
DS
= \DIRECTORY_SEPARATOR
public
mixed
HELPER_DIR
= __DIR__
redis
predis([mixed $host = '' ][, mixed $port = '' ][, mixed $auth = '' ]) : mixed
添加位置信息 predis_add_geo('places',[ [ 'lng'=>'116.397128', 'lat'=>'39.916527', 'title'=>'北京天安门' ], ]);
predis_add_geo(mixed $key[, mixed $arr = [] ]) : mixed
删除位置信息
predis_delete_geo(mixed $key[, mixed $arr = [] ]) : mixed
predis_delete_geo('places',[ '北京天安门', ]);
返回附近的地理位置 pr(predis_get_pager('places', 116.403958, 39.915049)); http://redisdoc.com/geo/georadius.html
predis_get_pager(mixed $key, mixed $lat, mixed $lng[, mixed $juli = 2 ][, mixed $sort = 'ASC' ][, mixed $to_fixed = 2 ]) : mixed
取lat lng
predis_geo_pos(mixed $key[, mixed $title = [] ][, mixed $to_fixed = 6 ]) : mixed
分组分页
array_to_pager(mixed $arr) : mixed
返回URL路径,不含有域名部分
get_url_remove_http(mixed $url) : mixed
取后缀
get_ext_by_url(mixed $url) : mixed
取mime
get_mime(mixed $url) : mixed
获取远程URL内容
get_remote_file(mixed $url[, mixed $is_json = false ]) : mixed
下载文件 建议使用 download_file_safe
download_file(mixed $url[, mixed $contain_http = false ]) : mixed
下载资源文件到本地
download_file_safe(mixed $url[, mixed $mimes = ['image/*', 'video/*'] ][, mixed $cons = [] ][, mixed $contain_http = false ]) : mixed
下载远程文件 global $remote_to_local_path; $remote_to_local_path = '/uploads/saved/'.date("Y-m-d");
download_remote_file(mixed $url[, mixed $path = '' ][, mixed $name = '' ]) : mixed
调用阿里云
curl_aliyun(mixed $url[, mixed $bodys = '' ][, mixed $method = 'POST' ]) : mixed
返回成功的json信息
success_data(mixed $data[, mixed $msg = '' ]) : mixed
返回失败的json信息
error_data(mixed $msg) : mixed
pathinfo /index.php/admin/auth/index?code=2 返回 admin/auth/index 数组时返回 ['admin','auth','index']
get_path_info([mixed $return_array = false ]) : mixed
支持pathinfo路由 未找到请用 pathinfo_not_find 函数
router_pathinfo([mixed $ns = 'app' ][, mixed $add_controller = 'controller' ][, mixed $ucfirst_controller = true ]) : mixed
生成数字随机数 一般用于核销 需要表名 rand_code 字段 nid code status默认0
make_rand_code(mixed $node_id) : mixed
核销后需要释放核销码
update_make_rand_code(mixed $node_id) : mixed
锁功能已替代 lock_call('k',functon(){
set_lock(mixed $key[, mixed $exp_time = 60 ]) : mixed
},second);
获取是否锁定
get_lock(mixed $key) : mixed
释放锁定
del_lock(mixed $key) : mixed
json数据替换
json_replace( $json[, $replace = [] ][, $return_json = true ]) : mixed
去除PHP代码注释
remove_php_notes(mixed $content) : mixed
在线查看office文件
online_view_office(mixed $url) : mixed
格式化输出金额 强制输出数字类型
printfs(mixed &$v[, mixed $keys = [] ][, mixed $dot = 2 ]) : mixed
float不进位,如3.145 返回3.14 进位的有默认round(3.145) 或sprintf("%.2f",3.145);
float_noup(mixed $float_number[, mixed $dot = 2 ]) : mixed
四舍五入
float_up(mixed $float_number[, mixed $dot = 2 ][, $mid_val = 5 ]) : mixed
加载xlsx load_xls([ 'file' => $xls, 'config'=>[ '序号' =>'index', ], 'title_line'=>1, 'call'=>function($i,$row,&$d){} ]);
load_xls([mixed $new_arr = [] ]) : mixed
获取文件行数,不包空行
get_lines(mixed $file[, mixed $length = 40960 ]) : mixed
返回请求中是http还是https
get_request_top() : mixed
返回请求域名及URL部分,不包含http://
get_request_host() : mixed
自动跳转到https网站
auto_jump() : mixed
get_http_full_url(mixed $url[, mixed $fun = 'cdn_url' ]) : mixed
从数组中搜索
get_index_array_valule(mixed $array, mixed $key, mixed $val) : mixed
gbk_substr(mixed $text, mixed $start, mixed $len[, mixed $gbk = 'GBK' ]) : mixed
GBK长宽 2个字符
get_gbk_len(mixed $value[, mixed $gbk = 'GBK' ]) : mixed
文字居中
get_text_c(string $str, int $len) : mixed
文字排版 左 中 右 左 右
get_text_lr(array<string|int, mixed> $arr, int $length[, mixed $return_arr = false ]) : mixed
处理跨域
allow_cross_origin() : mixed
to_utf8(mixed $str) : mixed
csv_reader(mixed $file) : mixed
csv_writer(mixed $file[, mixed $header = [] ][, mixed $content = [] ]) : mixed
基于redis锁
lock_call(mixed $key, mixed $call[, mixed $time = 10 ]) : mixed
global $redis_lock; //锁前缀 global $lock_key;
$redis_lock = [ 'host'=>'', 'port'=>'', 'auth'=>'', ];
lock_call('k',functon()},1); 或 if(lock_start('k')){ .. lock_end(); }
开始锁
lock_start(mixed $key[, mixed $time = 1 ]) : mixed
释放锁
lock_end() : mixed
compare_date(mixed $a, mixed $b) : mixed
发布消息 redis_pub("demo","welcome man"); redis_pub("demo",['title'=>'yourname']);
redis_pub(mixed $channel, mixed $message) : mixed
取订阅消息 redis_sub("demo",function($channel,$message){ echo "channel ".$channel."\n"; print_r($message); });
redis_sub(mixed $channel, mixed $call[, mixed $unsubscribe = false ]) : mixed
send_pusher([mixed $data = [] ][, mixed $channel = 'netteadmin' ][, mixed $event = 'notice' ]) : mixed
think_check_sign(mixed $json_string[, mixed $key = '' ][, mixed $sign_key = 'sign' ]) : mixed
think_create_sign([mixed $arr = [] ][, mixed $key = '' ]) : mixed
get_str_ord(mixed $str[, mixed $is_join = false ]) : mixed
gz_encode(mixed $arr_or_str) : mixed
gz_decode(mixed $str) : mixed
html_to_pdf(mixed $input_html_file, mixed $output_pdf_file[, mixed $return_cmd = false ][, mixed $exec = false ]) : mixed
https://github.com/picqer/php-barcode-generator/blob/main/src/BarcodeGenerator.php C128 C128A C128B C128C C93 EAN13 EAN8 EAN2
get_barcode(mixed $code[, mixed $type = 'C128' ][, mixed $widthFactor = 2 ][, mixed $height = 30 ][, mixed $foregroundColor = [0, 0, 0] ]) : mixed
text_add_br(mixed $text, mixed $w[, mixed $br = '<br>' ]) : mixed
get_server_headers([mixed $name = '' ]) : mixed
output_js_css([mixed $js = '' ][, mixed $css = '' ]) : mixed
xml2array(mixed $xml) : mixed
array2xml(mixed $arr[, mixed $root = '' ]) : mixed
copy_base64_data() : mixed
set_scss_path(mixed $path) : mixed
scss(mixed $css[, mixed $is_cached = false ]) : mixed
HTML端收消息 wss://yourdomain/wss ws://ip:port
get_ws_js(mixed $func[, mixed $ws = 'ws://127.0.0.1:3006' ]) : mixed
生成node js ws服务 需要把返回的内容写入server.js中 依赖 ioredis
create_node_ws_server([mixed $ws_port = 3006 ][, mixed $topic = ['demo'] ][, mixed $redis_host = '127.0.0.1' ][, mixed $port = '6379' ][, mixed $auth = '' ]) : mixed
xis_ssl() : mixed
xcookie(mixed $name[, mixed $value = '' ][, mixed $expire = 0 ]) : mixed
xcookie_delete(mixed $name) : mixed
根据公钥生成文件
license_create(mixed $data[, mixed $file = null ]) : mixed
获取授权信息
license_data([mixed $file = '' ]) : mixed
license_data_parse(mixed &$data) : mixed
授权是否过期
license_is_expire() : bool
授权是否接近过期
license_near_expire() : void
license_html() : mixed
激活平台数据库连接,平台数据库不支持从库读
pg_active_main() : mixed
激活读数据库连接
pg_active_read() : mixed
激活默认数据库连接
pg_active_default() : mixed
激活当前使用哪个数据库
pg_active([mixed $name = 'default' ]) : mixed
获取当前启用的数据库连接
get_pg_active_name() : mixed
判断是否可运行action
pg_can_run_action() : mixed
数据库是否可执行更新操作
pg_can_run_update([mixed $sql = '' ]) : mixed
连接数据库
new_pg([mixed $config = [] ][, mixed $name = '' ]) : mixed
数据库实例
medoo_pg() : object
pg() : mixed
pg_pager(mixed $table, mixed $join[, mixed $columns = null ][, mixed $where = null ]) : mixed
设置分页总记录数 一般情况用不到
pg_pager_count([mixed $nums = null ]) : mixed
显示分页 调用pg_pager后,再调用。 pg_pager_html([ 'url'=>'', ]);
pg_pager_html([mixed $arr = [] ]) : mixed
添加错误信息
pg_add_error(mixed $str) : mixed
获取错误信息
pg_get_error() : mixed
pg_get(mixed $table[, mixed $join = null ][, mixed $columns = null ][, mixed $where = null ]) : mixed
_pg_get(mixed $table[, mixed $join = null ][, mixed $columns = null ][, mixed $where = null ]) : mixed
$lists = pg_select('do_order', [ 'count' => 'COUNT(`id`)', 'total' => 'SUM(`total_fee`)', 'date' => "FROM_UNIXTIME(`inserttime`, '%Y-%m-%d')" ], 'WHERE `status` = 1 GROUP BY `date` LIMIT 30' );
pg_select(mixed $table[, mixed $join = "*" ][, mixed $columns = null ][, mixed $where = null ]) : mixed
写入记录
pg_insert(string $table[, array<string|int, mixed> $data = [] ][, mixed $don_run_action = false ]) : array<string|int, mixed>
表名
数据
更新记录
pg_update(string $table[, array<string|int, mixed> $data = [] ][, mixed $where = [] ][, mixed $don_run_action = false ]) : array<string|int, mixed>
表名
数据
数据库事务
pg_action(mixed $call) : mixed
对数据进行
pg_for_update(mixed $table, mixed $id) : mixed
根据表名、字段 、条件 查寻一条记录
pg_get_one(string $table[, mixed $join = "*" ][, mixed $columns = null ][, array<string|int, mixed> $where = null ]) : array<string|int, mixed>
表名
条件
SQL查寻
pg_query(mixed $sql[, mixed $raw = null ]) : mixed
取最小值 https://medoo.in/api/min min($table, $column, $where) min($table, $join, $column, $where)
pg_get_min(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
字段
条件
取最大值 max($table, $column, $where) max($table, $join, $column, $where)
pg_get_max(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
字段
条件
总数 count($table, $where) count($table, $join, $column, $where)
pg_get_count(string $table[, mixed $join = "*" ][, mixed $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
条件
是否有记录 has($table, $where) has($table, $join, $where)
pg_get_has(string $table[, mixed $join = null ][, array<string|int, mixed> $where = null ]) : void
表名
条件
随机取多条记录 rand($table, $column, $where) rand($table, $join, $column, $where)
pg_get_rand(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
字段
条件
取总和 sum($table, $column, $where) sum($table, $join, $column, $where)
pg_get_sum(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
字段
条件
取平均值 avg($table, $column, $where) avg($table, $join, $column, $where)
pg_get_avg(string $table[, mixed $join = "*" ][, string $column = null ][, array<string|int, mixed> $where = null ]) : void
表名
字段
条件
RAW https://medoo.in/api/raw raw('NOW()') raw('RAND()') raw('AVG(<age>)')
pg_raw(string $raw) : mixed
pg_del(mixed $table, mixed $where) : mixed
pg_delete(mixed $table, mixed $where) : mixed
显示所有表名
pg_tables(string $table) : void
表名
取表中字段
pg_fields(mixed $table[, mixed $has_key = true ]) : mixed
返回数据库允许的数据,传入其他字段自动忽略
pg_allow(mixed $table, mixed $data) : mixed
显示数据库表结构,支持markdown格式
pg_tables_markdown([string $name = null ][, mixed $show_markdown = false ]) : mixed
数据库名
取表中json字段
pg_field_json(mixed $table) : mixed
判断表中的字段是不是json
pg_field_is_json(mixed $table, mixed $field) : mixed
把数据库中json字段转成array
pg_row_json_to_array( $table_name[, &$row_data = [] ]) : mixed
array_order_by() : mixed
is_json(mixed $data[, mixed $assoc = false ]) : mixed
add_action(mixed $name, mixed $call[, mixed $level = 20 ]) : mixed
do_action(mixed $name[, mixed &$par = null ]) : mixed
返回两个日期之间 $date1 = '2022-11-01'; $date2 = '2022-12-14'; 字段是datetime类型
pg_between_date(mixed $field, mixed $date1, mixed $date2) : mixed
返回两个月份之间 $date1 = '2022-11'; $date2 = '2022-12'; 字段是datetime类型
pg_between_month(mixed $field, mixed $date1, mixed $date2) : mixed
rpc_client(mixed $url[, mixed $is_remote = false ]) : mixed
rpc_server(mixed $class) : mixed
rpc_token() : mixed
尝试多次运行 $times 运行次数 $usleep_time 毫秒
call_retry(mixed $func[, mixed $times = 3 ][, mixed $usleep_time = 1000 ]) : mixed
数组转tree
array_to_tree(mixed $list[, mixed $pk = 'id' ][, mixed $pid = 'pid' ][, mixed $child = 'children' ][, mixed $root = 0 ][, mixed $my_id = '' ]) : mixed
输入$list [ {id:1,pid:0,其他字段}, {id:2,pid:1,其他字段}, {id:3,pid:1,其他字段}, ] 输出 [ [ id:1, pid:0, 其他字段, children:[ {id:2,pid:1,其他字段}, {id:3,pid:1,其他字段}, ] ] ]
数组或字符输出,方便查看
pr(mixed $str) : mixed
add_action(mixed $name, mixed $call[, mixed $level = 20 ]) : mixed
do_action(mixed $name[, mixed &$par = null ]) : mixed
is_cli() : mixed
is_post() : mixed
is_json(mixed $data[, mixed $assoc = false ]) : mixed
array_to_object(mixed $arr) : mixed
object_to_array(mixed $obj) : mixed
get_dir(mixed $name) : mixed
get_ext(mixed $name) : mixed
get_name(mixed $name) : mixed
create_dir_if_not_exists(mixed $arr) : mixed
is_local() : mixed
get_ip([mixed $type = 0 ][, mixed $adv = false ]) : mixed
now() : mixed
get_distance(mixed $longitude1, mixed $latitude1, mixed $longitude2, mixed $latitude2[, mixed $unit = 2 ][, mixed $decimal = 2 ]) : mixed
get_deep_dir(mixed $path) : mixed
price_format(mixed $yuan[, mixed $dot = 2 ]) : mixed
json([mixed $arr = [] ]) : mixed
json_error([mixed $arr = [] ][, mixed $is_array = false ]) : mixed
json_success([mixed $arr = [] ][, mixed $is_array = false ]) : mixed
yaml_load(mixed $str) : mixed
yaml_dump(mixed $array[, mixed $line = 3 ]) : mixed
yaml(mixed $str) : mixed
aes_encode(mixed $data[, mixed $key = '' ][, mixed $iv = '' ][, mixed $type = 'AES-128-CBC' ][, mixed $options = '' ]) : mixed
aes_decode(mixed $data[, mixed $key = '' ][, mixed $iv = '' ][, mixed $type = 'AES-128-CBC' ][, mixed $options = '' ]) : mixed
string_to_array(mixed $name[, mixed $array = '' ]) : mixed
get_dates(mixed $start, mixed $end[, mixed $contain_last = true ]) : mixed
get_date_china(mixed $date) : mixed
timeago(mixed $time) : mixed
is_ajax() : mixed
import(mixed $file[, mixed $vars = [] ][, mixed $check_vars = false ]) : mixed
get_reffer([mixed $refer = '' ]) : mixed
get_root_domain([mixed $host = '' ]) : mixed
get_sub_domain([mixed $host = '' ]) : mixed
sign_by_secret(mixed $params[, mixed $secret = '' ][, mixed $array_encode = false ]) : mixed
zip_extract(mixed $local_file, mixed $extract_local_dir) : mixed
zip_create(mixed $local_zip_file[, mixed $files = [] ]) : mixed
is_json_request() : mixed
array_to_el_select(mixed $all, mixed $v, mixed $k) : mixed
echats(mixed $ele[, mixed $options = [] ]) : mixed
echats_reload() : mixed
echarts(mixed $ele[, mixed $options = [] ]) : mixed
echarts_reload() : mixed
设置允许字段
set_field_allow(mixed $collect, mixed $field) : mixed
获取允许字段
get_field_allow(mixed $collect) : mixed
返回允许字段值
get_data_allow(mixed $collect, mixed $input) : mixed
is_ssl() : mixed
think_validate(mixed $labels, mixed $data, mixed $rules[, mixed $show_array = false ]) : mixed
validate(mixed $labels, mixed $data, mixed $rules[, mixed $show_array = false ]) : mixed
jump(mixed $url) : mixed
对数组添加cdn url
set_url_use_cdn(mixed &$row[, mixed $field = [] ]) : mixed
添加到队列 "topthink/think-queue": "^3" push_task('app\printer\job\Printer',['tt'=>11],'');
push_task(mixed $job[, mixed $data = '' ][, mixed $queue = '' ]) : mixed
向上取递归 如当前分类是3,将返回 123所有的值 $arr = loop_tree("catalog",$v['catalog_id'],true); foreach($arr as $vv){ $title[] = $vv['title']; } id pid 1 0 2 1 3 2
loop_tree(mixed $table, mixed $id[, mixed $is_frist = true ]) : mixed
向下递归
get_loop_tree_ids(mixed $table, mixed $id[, mixed $where = [] ][, mixed $get_field = 'id' ]) : mixed
递归删除
loop_del(mixed $table, mixed $id[, mixed $where = [] ]) : mixed
用于tree表格排序 因为tree给的lists字段是用于显示,在排序时得到的index是不正确的, 此时需要lists_sort字段得到正确的index 在交换排序值时才能正确保存并显示
el_table_tree(mixed $list, mixed $j[, mixed $is_top = false ]) : mixed
用于cascader字段 public function cascader(){ $catalog = db_get($this->table,"*",[ 'ORDER'=>catalog_default_order_by(), 'status'=>1 ]); $select = el_cascader(array_to_tree($catalog)); json_success(['data'=>$select]); } $catalog = db_get("catalog",[]); $select = el_cascader(array_to_tree($catalog));
el_cascader(mixed $select[, mixed $label = 'title' ][, mixed $value = 'id' ]) : mixed
内部实现
_loop_del_tree(mixed $table, mixed $all) : mixed
内部实现
_loop_tree_deep_inner(mixed $all, mixed $get_field[, mixed $is_frist = false ]) : mixed
get_xss_clean_ins() : mixed
xss_clean_str(mixed $str) : mixed
xss_clean(mixed $input) : mixed
global_trim() : mixed
global_trim_inner(mixed &$in) : mixed
get([mixed $key = "" ]) : mixed
get_req_post([mixed $key = "" ]) : mixed
g([mixed $key = null ]) : mixed
get_input() : mixed
guzzle_http([mixed $click_option = [] ]) : mixed
guzzle_http_fake_option() : mixed
get_template(mixed $name[, mixed $replace_arr = [] ]) : mixed
获取接口请求数据,如果存在将不发起接口请求
get_api_data(mixed $title, mixed $name) : mixed
记录接口请求数据
api_data_insert([mixed $data = [] ]) : mixed
cookie(mixed $name[, mixed $value = '' ][, mixed $expire = 0 ]) : mixed
cookie_delete(mixed $name) : mixed
激活数据库连接
active_db([mixed $value = 'mongo' ]) : mixed
使用默认monogo连接
active_db_default() : mixed
group by 查寻
db_get_group(mixed $table[, mixed $field = [] ][, mixed $options = [] ][, mixed $is_pager = false ]) : mixed
mongodb groupby兼容
_db_group_con(mixed $k, mixed $value[, mixed $up_value = '' ]) : mixed
db_set_field_type(mixed $table, mixed $data) : mixed
权限字段类型设置值
db_reset_data_by_filed_type(mixed $table, mixed &$data) : mixed
数据库更新记录
db_update(mixed $table, mixed $update_data, mixed $where[, mixed $use_action = true ]) : mixed
数据库删除记录
db_del(mixed $table, mixed $where) : mixed
向数据库添加记录
db_insert(mixed $table, mixed $data[, mixed $use_action = true ]) : mixed
内部调用,处理 where条件是数组的情况
_db_get_when_array(mixed $list, mixed $call) : mixed
数据库查寻
db_get_one(mixed $table, mixed $field[, mixed $call = null ]) : mixed
设置数据库查寻字段走缓存
set_db_cache(mixed $table, mixed $field) : mixed
取缓存key
get_db_cache_key(mixed $table, mixed $where) : mixed
取缓存where
get_db_cache_where(mixed $table, mixed $where) : mixed
取数据,带缓存
db_get_cache(mixed $table[, mixed $where = [] ][, mixed $limit = null ]) : mixed
取数据
db_get(mixed $table[, mixed $field = null ][, mixed $call = null ][, mixed $limit = null ]) : mixed
数量
db_get_count(mixed $table, mixed $call) : mixed
计算SUM
db_get_sum(mixed $table, mixed $field, mixed $call) : mixed
数据库分页
db_pager(mixed $table[, mixed $field = [] ][, mixed $call = [] ]) : mixed
分页
db_get_pager(mixed $table, mixed $call) : mixed
mongodb事务
db_action(mixed $call) : mixed
mongo_action(mixed $call) : mixed
数据库字段允许
db_allow(mixed $table, mixed $data) : mixed
设置允许字段
db_allow_set(mixed $table, mixed $data) : mixed
设置或取ID
get_id_by_auto_insert(mixed $table[, mixed $data = [] ][, mixed $where = [] ][, mixed $has_time_and_update = false ]) : mixed
取一条或多条记录 get_all_or_one("novel_book",$where,'get_novel_book_row');
get_all_or_one(mixed $table, mixed $where[, mixed $fun = '' ][, mixed $limit = '' ]) : mixed
set_config(mixed $title, mixed $body) : mixed
get_config(mixed $title) : mixed
获取ENV
get_env(mixed $key) : mixed
设置ENV
set_env(mixed $key, mixed $val) : mixed
季度 返回 k=>{0:开始 1:结束 flag:}
vue_get_jidu([mixed $time = '' ]) : mixed
每个季度开始、结束时间
vue_get_jidu_array(mixed $year) : mixed
某月的最后一天
vue_get_last_day([mixed $month = '2023-07' ]) : mixed
vue message
vue_message() : mixed
loading效果
vue_loading([mixed $name = 'load' ][, mixed $txt = '加载中' ]) : mixed
Encodes a PHP variable into javascript representation.
php_to_js(mixed $value[, bool $safe = false ]) : string
Example:
$options=array('key1'=>true,'key2'=>123,'key3'=>'value');
echo php_to_js($options);
// The following javascript code would be generated:
// {'key1':true,'key2':123,'key3':'value'}
For highly complex data structures use and to serialize and unserialize.
If you are encoding user input, make sure $safe is set to true.
PHP variable to be encoded
If true, 'js:' will not be allowed. In case of wrapping code with JavaScript expression will stay as is no matter what value this parameter is set to. Default is false. This parameter is available since 1.1.11.
the encoded string
yii_quote(mixed $js[, mixed $forUrl = false ]) : mixed