文章分类 -  PHP

摘要:我们在项目开发中,会在某些情况会使用到 对指定的一些id需要进行优先查询,下面是使用方法 原生mysql查询例子: SELECT * from order WHERE status =1 order by field(id,11339,7005,3346) 在THINKPHP中可以这样使用: $id 阅读全文
posted @ 2022-03-23 17:07 智昕 阅读(129) 评论(0) 推荐(0) 编辑
摘要://base64图片保存 function base64Save($base64Image){ //接收base64数据 image=base64Image; //设置图片名称 $imageName = "l_".date("His",time())."_".rand(1111,9999).' 阅读全文
posted @ 2022-03-22 16:08 智昕 阅读(2225) 评论(0) 推荐(29) 编辑
摘要:这几天在研究MQTT协议以及protobuf,现在做安装protobuf扩展,特此记录 php-protobuf仓库地址https://github.com/allegro/php-protobuf 1、克隆代码 git clone https://github.com/allegro/php-pr 阅读全文
posted @ 2021-11-15 23:48 智昕 阅读(476) 评论(0) 推荐(10) 编辑
摘要:先通过composer安装elasticsearch composer require elasticsearch/elasticsearch 示例代码: <?php namespace app\controller; use app\BaseController; use Elasticsearc 阅读全文
posted @ 2021-11-12 18:04 智昕 阅读(1424) 评论(0) 推荐(17) 编辑
摘要:/** * 根据开始时间 和结束时间 循环生成期间内的时间信息 * @param formatdate@returnarray/functiondaytimearray(start_time,$end_time){ daylist=array();day_key 阅读全文
posted @ 2021-09-30 16:18 智昕 阅读(121) 评论(0) 推荐(1) 编辑
摘要:我们在模型中使用条件进行软删除发现删除无效,文档上也有写 软删除的删除操作仅对模型的删除方法有效,如果直接使用数据库的删除方法则无效,例如下面的方式无效。 user=newUser;user->where('id',1)->delete(); 使用下面闭包可以进行条件查询并进行软删除 U 阅读全文
posted @ 2021-09-27 14:37 智昕 阅读(728) 评论(0) 推荐(13) 编辑
摘要:在开发过程中会遇到多表关联查询的情况,这次使用三个表做关联查询表1:rate 表2:rate_acfee表3:rate_acfee_info表1的一条数据对应着表2的多条数据,表2的一条数据对应着表3的多条数,使用方法如下表1模型Rate: /** * 费率Model * Class Produce 阅读全文
posted @ 2021-09-19 19:39 智昕 阅读(4353) 评论(0) 推荐(34) 编辑
摘要:今天用到下载微信文章里的素材到服务器本地,写下以下方法,以做记录 //下载远程图片至本地 function downloadImageFromWeixin($url) { ch=curlinit(url); curl_setopt($ch, CURLOPT_HEADER, 0); curl 阅读全文
posted @ 2021-03-16 14:52 智昕 阅读(111) 评论(0) 推荐(1) 编辑
摘要:在生成或保存文件时我们经常会遇到文件夹不存在时报错的情况,使用以下方法即可解决 //判断文件夹是否存在,没有则新建 function path_exists($path){ if (!function_exists($path)) { mkdirs($path); } } //创建文件夹 funct 阅读全文
posted @ 2021-03-16 14:50 智昕 阅读(2488) 评论(0) 推荐(19) 编辑
摘要:方法如下: //生成前六个月 function to_sex_month($mun){ arr=array();for(i = 1;i<=mun; ++$i){ t=strtotime("i month"); arr[]=date(Ym,t); } retu 阅读全文
posted @ 2021-02-19 14:26 智昕 阅读(596) 评论(0) 推荐(3) 编辑
摘要://获取字符串中的域名 function getStringUrl($Text) { parttern="/http[s]?:\/\/(?:[azAZ]|[09]|[-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+/"; preg_matc 阅读全文
posted @ 2021-02-04 16:53 智昕 阅读(940) 评论(0) 推荐(3) 编辑
摘要:在用户访问时我们可以使用PHP的全局变量SERVER访//UserAgent:_SERVER['HTTP_USER_AGENT']; // 当前返回结果:Mozilla/5.0 (Windows NT 10.0; WOW64) 阅读全文
posted @ 2021-01-14 17:17 智昕 阅读(689) 评论(0) 推荐(8) 编辑
摘要:这次要开发聊天系统 , 需要用到WebSocket 我使用的是workerman+gateway,为了方便后面再用,做个简单记录 首先要特别注意的是,端口要开放,如果端口未开放,会出现连接时握手失败的情况,这里我用的商品是 801 和 802 1、安装workerman和gateway compos 阅读全文
posted @ 2021-01-14 12:41 智昕 阅读(970) 评论(0) 推荐(6) 编辑
摘要:今天生成订单号时,使用了最简便的订单号生成方法 uniqid uniqid() 函数基于以微秒计的当前时间,生成一个唯一的 ID。 uniqid().rand(1000,9999);//并在后面加了四位随机数 现在在用的方法 date('Ymd').substr(implode(NULL, arra 阅读全文
posted @ 2020-12-31 11:48 智昕 阅读(577) 评论(0) 推荐(4) 编辑
摘要:生成配置文件 /** * 生成配置文件 * @param string configPath@paramarrayconfig 配置数组 */ function createConfigFile(configPath,config=array()){ //获取配置内容 阅读全文
posted @ 2020-12-10 16:17 智昕 阅读(1204) 评论(0) 推荐(8) 编辑
摘要:今天在THINKPHP5上安装Workerman时报 Problem 1 - topthink/think-worker v3.0.5 requires topthink/framework ^6.0.0 -> satisfiable by topthink/framework[6.0.x-dev, 阅读全文
posted @ 2020-11-19 14:47 智昕 阅读(1861) 评论(0) 推荐(13) 编辑
摘要:在项目中用到小程序支付,费话不多说上代码 因为我这涉及么微信的很多开发功能 所以我把公共的方法放到的公共类中 WechatPublic <?php namespace app\zhonglian\controller\wechat; use app\BaseController; use think 阅读全文
posted @ 2020-11-04 16:35 智昕 阅读(2350) 评论(0) 推荐(11) 编辑

点击右上角即可分享
微信分享提示