<?php

namespace app\common\api;

use think\facade\Db;

/**
 * Description of LocationApi
 *
 * @author sgq
 */
class LocationApi {

    public static function findProvinceSelect() {
        $where = [];
        $where[] = ["code", "like", "%0000"];
        return Db::table("un_common_location")->where($where)->select()->toArray();
    }

    /**
     * 通过地区代码获取地区名
     * @param type $code
     * @param type $isfull
     * @return type
     */
    public static function getNameByCode($code, $isfull = false) {
        $where = [];
        $where[] = ["code", "=", $code];
        $field = $isfull ? "fullName" : "name";
        return Db::table("un_common_location")->where($where)->find()[$field];
    }

}