随笔分类 -  php

摘要:public function arr2tree($list, $id = 'id', $pid = 'pid', $son = 'children') { list($tree, $map) = [[], []]; $map = array_column($list, null, $id); fo 阅读全文
posted @ 2022-06-14 13:49 可爱香草 阅读(17) 评论(0) 推荐(0)
摘要:中文文档: //等值数组查询 where('domain', 'elemmatch',['selfbuild_brand_id'=> $date['selfbuild_brand_id']]) //数组模糊查询 用正则表达式实现 use MongoDB\BSON\Regex; where('doma 阅读全文
posted @ 2022-02-28 15:49 可爱香草 阅读(19) 评论(0) 推荐(0)
摘要:之前一直用exception 捕捉异常 后来发现一次异常捕捉不到了(其实是错误) 7以上exception与error是分开的 Throwable does not work on PHP 5.x. To catch both exceptions and errors in PHP 5.x and 阅读全文
posted @ 2022-01-27 14:15 可爱香草 阅读(47) 评论(0) 推荐(0)
摘要:简单查询 // 例如字段filed内容 {"time":"2012-12-01"} where("filed->time","2012-12-01") 数组查询 // 字段field 内容[{"time":"2012-12-01"}] ->whereJsonContains("field ",["t 阅读全文
posted @ 2022-01-14 21:30 可爱香草 阅读(90) 评论(0) 推荐(0)
摘要:$sql = UserRelationMap::select('inviter_id','business_id', DB::raw('COUNT(id) as num,any_value(id) as id,any_value(project_id) as project_id,any_value 阅读全文
posted @ 2022-01-12 16:44 可爱香草 阅读(20) 评论(0) 推荐(0)
摘要://先group分组 $sql = BlindBox::selectRaw('any_value(id) as id, any_value(business_id) as business_id,project_id,SUM(access_count) as access_count,SUM(joi 阅读全文
posted @ 2022-01-11 17:16 可爱香草 阅读(54) 评论(0) 推荐(0)
摘要:很多接口我们会遇到["6","10"] 这样的字符串数组,可是我们需要的是[6,10] 这里推荐一种不用循环解决的方案: $str = ["6","10"]; $str = json_decode('[' . $str. ']', true);//[6,10] 阅读全文
posted @ 2021-10-18 16:44 可爱香草 阅读(16) 评论(0) 推荐(0)
摘要:$refer = [];//临时数组 $tree = [];//树状结构 $list = [];//二维带level foreach ($data as $key => $value) { $refer[$value['id']] = &$data[$key]; } foreach ($data a 阅读全文
posted @ 2021-09-24 17:35 可爱香草 阅读(11) 评论(0) 推荐(0)
摘要:在passport v10以上已经移除了相关设置接口,我们可以重写createToken方法实现指定客户端ID public function createToken($name, array $scopes = []) { $clients = new ClientRepository('9466 阅读全文
posted @ 2021-09-22 10:42 可爱香草 阅读(18) 评论(0) 推荐(0)
摘要:public static function ListToTree($list, $primaryKey='id', $parentKey = 'up_id', $childStr = 'children', $root = 0) { $tree = array(); if (is_array($l 阅读全文
posted @ 2021-05-21 15:48 可爱香草 阅读(10) 评论(0) 推荐(0)
摘要:有时遇到本地文件明明没修改,pull提示文件修改的错误 error: Your local changes to the following files would be overwritten by merge: Please commit your changes or stash them b 阅读全文
posted @ 2021-05-06 16:42 可爱香草 阅读(27) 评论(0) 推荐(0)
摘要:余数一定小于除数,用10作为除数 可以把user表拆分成user0.......user9 根据id 可以确定用户存在哪个表中 查询所有数据 for ($i = 0; $i < 10; $i++) { $queries->push(DB::table('user_operator_record' . 阅读全文
posted @ 2021-04-26 14:47 可爱香草 阅读(57) 评论(0) 推荐(0)
摘要:curl 有时返回结果会含有头部信息需要处理 $curl = curl_init($url); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_HEADER, true); curl_set 阅读全文
posted @ 2021-01-25 15:49 可爱香草 阅读(26) 评论(0) 推荐(0)