ZdXzqService.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\service;
  3. use app\model\ZdXzq;
  4. class ZdXzqService
  5. {
  6. public static function getXzq(){
  7. $condition[] = ["xzqdm","like","%"."00000"];
  8. $condition[]=["xzqdm","<>","340000000"]; //去除安徽省选项
  9. $city = (new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($condition)->select();
  10. for ($i=0;$i<count($city);$i++){
  11. $map[$i][]=["xzqdm","NOTLIKE","%"."00000"];
  12. $map[$i][]=["xzqdm","like",[substr($city[$i]["id"],0,4)."%"."000"],"AND"];
  13. $city[$i]["children"]=(new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($map[$i])->select();
  14. for ($j=0;$j<count($city[$i]["children"]);$j++){
  15. $maptown[$j][$i][]=["xzqdm","NOTLIKE","%"."000"];
  16. $maptown[$j][$i][]=["xzqdm","LIKE",substr($city[$i]["children"][$j]["id"],0,6)."%","AND"];
  17. $city[$i]["children"][$j]["children"]=(new ZdXzq)->field("xzqdm as id, xzqmc as name")->where($maptown[$j][$i])->select();
  18. }
  19. }
  20. return $city;
  21. }
  22. public static function getXzqDetail($xzqdm){
  23. return ZdXzq::where("xzqdm",$xzqdm)->find();
  24. }
  25. }