Example #1
0
    public static function getActiveCity()
    {
        if (self::$_activeCity === null) {
            $ownerActiveCond = '';
            if (param('useUserads')) {
                $ownerActiveCond = ' AND ap.owner_active = ' . Apartment::STATUS_ACTIVE . ' ';
            }
            $sql = 'SELECT ac.name_' . Yii::app()->language . ' AS name, ac.id AS id
					FROM {{apartment}} ap, {{apartment_city}} ac
					WHERE ac.id = ap.city_id
					AND ap.price_type IN (' . implode(',', array_keys(Apartment::getPriceArray(Apartment::PRICE_SALE, true))) . ')
					AND ap.active = ' . Apartment::STATUS_ACTIVE . ' ' . $ownerActiveCond . '
					ORDER BY ac.sorter';
            $results = Yii::app()->db->createCommand($sql)->queryAll();
            self::$_activeCity = CHtml::listData($results, 'id', 'name');
        }
        return self::$_activeCity;
    }