网站虚假备案,盘丝洞app破解无限盘币,东莞微信网站,做网站app 需要多少钱数据库中遇到的操作 查询字段是json的某个值 //获取数据库中某个字段是json中得某个值#xff0c;进行查询#xff0c;goods是表中字段#xff0c;brand_id是json中要查詢的字段。//数据类型一定要对应要不然查询不出来。$map[json_extract(goods, $.brand_id)]…数据库中遇到的操作 查询字段是json的某个值 //获取数据库中某个字段是json中得某个值进行查询goods是表中字段brand_id是json中要查詢的字段。//数据类型一定要对应要不然查询不出来。$map[json_extract(goods, $.brand_id)] (int)$params[brand_id]; 查询结果进行遍历操作 db(product_plant)-where($map)-order(id, desc)-paginate($limit)-each(function ($item, $key) use ($store_id) {//代码逻辑多级下拉
if (isset($params[cat]) !empty($params[cat])) {if (count($params[cat]) 1) {$shop_cat_array model(store_category)-where([pid$params[cat][0], store_id$this-auth-id])-column(id);$cat model(store_category)-where(pid, in, $shop_cat_array)-where(store_id, $this-auth-id)-column(id);$map[shop_cat] [in, $cat];}else if (count($params[cat]) 2) {$cat model(store_category)-where([pid$params[cat][1], store_id$this-auth-id])-column(id);$map[shop_cat] [in, $cat];}else {$map[shop_cat] $params[cat][2];}}UNION的使用 $field p.id;
$sql db(product)-alias(p)-field($field)-where($where)-union(function ($query) use ($where,$field) {$query-name(store_product)-alias(p)-field($field)-where($where);
}, true)-buildSql();
$model Db::table($sql . as a);
$productIds $model-column(id);
$map[product_id] [in, $productIds];//获取当前域名
//$domian $this-request-domain()//array_merge可以写在where条件里整合
//$bill_money db(store_bill)-where(array_merge([comein1],$w))-sum(price)
// -db(store_bill)-where(array_merge([comein0],$w))-sum(price);查看数据库中json字段不符合json结构的 -- 不符合json结构不能使用json_container()SELECT * FROM hzqc_product_plant WHERE JSON_VALID(goods) 0;SELECT * FROM hzqc_product_plant WHERE store_id 91000003 AND json_extract(goods, $.brand_id) 6074
SELECT * FROM hzqc_product_plant WHERE store_id 91000003 AND goods-$.brand_id 6074; php密码设置 $params[salt] Random::alnum();
$params[password] md5(md5($params[password]) . $params[salt]);常用的一些东西可以放到common.php中在使用的时候直接调用
if (!function_exists(cdnurl)) {/*** 获取上传资源的CDN的地址* param string $url 资源相对地址* return string*/function cdnurl($url) {return preg_match(/^https?:\/\/(.*)/i, $url) ? $url : think\Config::get(upload.cdnurl) . $url;}
}//常用常量参数也可以放到common中
if (!function_exists(mall_payment_type)) {function mall_payment_type($code 9) {$result [wechat微信支付, alipay支付宝, credit信用支付, transfer对公转账, deposit预付款, zero零元领取礼包, mixed混合支付];return ($code 9) ? $result : $result[$code]??;}
}//随机获取一个IP
if (!function_exists(rand_id)) {function rand_id(){$data array(119.120...rand(1,255)...rand(1,255),124.174...rand(1,255)...rand(1,255),116.249...rand(1,255)...rand(1,255),118.125...rand(1,255)...rand(1,255),42.175...rand(1,255)...rand(1,255),124.162...rand(1,255)...rand(1,255),211.167...rand(1,255)...rand(1,255),58.206...rand(1,255)...rand(1,255),117.24...rand(1,255)...rand(1,255),203.93...rand(1,255)...rand(1,255),);//随机获取一个IP地址$ip $data[array_rand($data)];return $ip;}
}