123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace app\service;
- use app\model\ZdXzq;
- class ZdXzqService
- {
- public static function getXzq(){
- $condition[] = ["xzqdm","like","%"."00000"];
- $condition[]=["xzqdm","<>","340000000"]; //去除安徽省选项
- $city = (new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($condition)->select();
- for ($i=0;$i<count($city);$i++){
- $map[$i][]=["xzqdm","NOTLIKE","%"."00000"];
- $map[$i][]=["xzqdm","like",[substr($city[$i]["id"],0,4)."%"."000"],"AND"];
- $city[$i]["children"]=(new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($map[$i])->select();
- for ($j=0;$j<count($city[$i]["children"]);$j++){
- $maptown[$j][$i][]=["xzqdm","NOTLIKE","%"."000"];
- $maptown[$j][$i][]=["xzqdm","LIKE",substr($city[$i]["children"][$j]["id"],0,6)."%","AND"];
- $city[$i]["children"][$j]["children"]=(new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($maptown[$j][$i])->select();
- }
- }
- return $city;
- }
- public static function getXzqDetail($xzqdm){
- return ZdXzq::where("xzqdm",$xzqdm)->find();
-
- }
- }
|