LocationApi.php 735 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\api;
  3. use think\facade\Db;
  4. /**
  5. * Description of LocationApi
  6. *
  7. * @author sgq
  8. */
  9. class LocationApi {
  10. public static function findProvinceSelect() {
  11. $where = [];
  12. $where[] = ["code", "like", "%0000"];
  13. return Db::table("un_common_location")->where($where)->select()->toArray();
  14. }
  15. /**
  16. * 通过地区代码获取地区名
  17. * @param type $code
  18. * @param type $isfull
  19. * @return type
  20. */
  21. public static function getNameByCode($code, $isfull = false) {
  22. $where = [];
  23. $where[] = ["code", "=", $code];
  24. $field = $isfull ? "fullName" : "name";
  25. return Db::table("un_common_location")->where($where)->find()[$field];
  26. }
  27. }