Exemplo n.º 1
0
/**
*@param int $parent_id 父id
*@return array $arr  有层级的数组
*/
function digui($arrayinfo = array(), $parent_id = 0)
{
    global $db, $ecs;
    $data = read_static_cache('city_tree_68');
    if ($data !== false && is_array($data)) {
        return $data;
    }
    if (empty($arrayinfo)) {
        $sql = "select * from " . $ecs->table('region');
        $arrayinfo = $db->getAll($sql);
    }
    $arr = array();
    foreach ($arrayinfo as $key => $val) {
        if ($val['parent_id'] == $parent_id) {
            $region_id = $val['region_id'];
            $arr[$region_id] = array('id' => $region_id, 'text' => $val['region_name'], 'level' => $val['region_type'], 'parent_id' => $val['parent_id']);
            unset($arrayinfo[$key]);
            $arr[$region_id]['child'] = digui($arrayinfo, $region_id);
            if (empty($arr[$region_id]['child'])) {
                $arr[$region_id]['child'] = null;
            }
        }
    }
    write_static_cache('city_tree_68', $arr);
    return $arr;
}
Exemplo n.º 2
0
function insert_get_all_regions($arr)
{
    global $smarty;
    $need_cache = $smarty->caching;
    $need_compile = $smarty->force_compile;
    $showCity = digui();
    $html = xuanran($showCity);
    $smarty->assign('html', $html);
    $smarty->assign('store_id', $arr['store_id']);
    $val = $smarty->fetch('city_tree.htm');
    $smarty->caching = $need_cache;
    $smarty->force_compile = $need_compile;
    return $val;
}