企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 数组转数据库IN查询字符串 ``` // 数组转数据库IN查询字符串 function arrToInStr($array=[],$field,$type=0){ if($type){ $string = join(",",array_column($array,$field)); }else{ $string = "'".join("','",array_column($array,$field))."'"; } return $string; } ``` ``` # 例子: // 获取经销商地址 function getAgenAddressStr($agent_guid){ $area = Db::name("agent_area") ->where(['agent_guid'=>$agent_guid]) ->select(); $address = ""; if ($area){ foreach ($area as $k=>$v){ $address .= "'".$v['province'].",".$v['city'].",".$v['area']."',"; } $address = trim($address,","); } return $address; } ```