catalog/model/localisation/city.php

(完整代码) 1KB

<?php

/**
 * Localisation city Model for frontend.
 *
 * @copyright  2016 damicms.com - All Rights Reserved
 * @link       http://www.guangdawangluo.com
 * @author     Edward Yang <yangjin@damicms.com>
 * @created    2016-11-10 11:39:20
 * @modified   2016-11-10 11:58:58
 */
class ModelLocalisationCity extends Model
{
    public function getCity($city_id)
    {
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "city WHERE city_id = '" . (int)$city_id . "'");

        return $query->row;
    }

    public function getCities()
    {
        $city_data = $this->cache->get('city.status');

        if (!$city_data) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "city WHERE status = '1' ORDER BY name ASC");

            $city_data = $query->rows;

            $this->cache->set('city.status', $city_data);
        }

        return $city_data;
    }

    public function getCitiesByZoneId($zoneId, $topLevel = true)
    {
        $cacheKey = 'city.' . (int)$zoneId . '_' . (int)$topLevel;
        $city_data = $this->cache->get($cacheKey);

        if (!$city_data) {
            if ($topLevel) {
                $sql = "SELECT * FROM " . DB_PREFIX . "city WHERE zone_id = '" . (int)$zoneId . "' AND status = '1' AND up_id=0 ORDER BY name";
            } else {
                $sql = "SELECT * FROM " . DB_PREFIX . "city WHERE up_id = '" . (int)$zoneId . "' AND status = '1' ORDER BY name";
            }
            $query = $this->db->query($sql);

            $city_data = $query->rows;
            $this->cache->set($cacheKey, $city_data);
        }

        return $city_data;
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。