Fungsi untuk mendapatkan data kota di Indonesia
@param integer $province_id ID propinsi
@param integer $city_id ID kota, jika ID propinsi dan kota NULL maka tampilkan semua kota
@return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
774550
public function city($province_id = NULL, $city_id = NULL) {
        $params = (is_null($province_id)) ? array() : array('province' => $province_id);
        if (!is_null($city_id)) {
            $params['id'] = $city_id;
        }
        $rest_client = new RESTClient($this->api_key, 'city', $this->account_type);
        return $rest_client->get($params);
    }
981519
public function country($country_id, Request $request = null)
    {
        $country = Country::with('zone')->find($country_id);

        if ($request) {
            $included = [];
            $query = $country->getInlcudeResources($request->include);
            if ($query) {
                $collection = new Collection(
                    $query,
                    str_singular($request->include)
                );
                $included = $collection->toArray();
            }
            $links = $request ? ['self' => $request->url()] : [];
            return $this->respondWithItem(
                $country,
                'country',
                $links,
                $included
            );
        }
        return $country;
    }
1024310
public function findByName($name, $city = null)
    {
        if (strlen($name) < 3) {
            throw new InvalidArgumentException('Zadejte minimálně 3 znaky pro hledání.');
        }

        $url = $this->wrapUrl(sprintf(
            self::URL_FIND,
            urlencode(Lib::stripDiacritics($name)),
            urlencode(Lib::stripDiacritics($city))
        ));

        $cachedFileName = date($this->cacheStrategy).'_'.md5($name.$city).'.php';
        $cachedFile = $this->cacheDir.'/find_'.$cachedFileName;
        $cachedRawFile = $this->cacheDir.'/find_raw_'.$cachedFileName;

        if (is_file($cachedFile)) {
            return unserialize(file_get_contents($cachedFile));
        }

        $aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
        if ($this->debug) {
            file_put_contents($cachedRawFile, $aresRequest);
        }
        $aresResponse = simplexml_load_string($aresRequest);
        if (!$aresResponse) {
            throw new AresException('Databáze ARES není dostupná.');
        }

        $ns = $aresResponse->getDocNamespaces();
        $data = $aresResponse->children($ns['are']);
        $elements = $data->children($ns['dtt'])->V->S;

        if (empty($elements)) {
            throw new AresException('Nic nebylo nalezeno.');
        }

        $records = new AresRecords();
        foreach ($elements as $element) {
            $record = new AresRecord();
            $record->setCompanyId(strval($element->ico));
            $record->setTaxId(
                ($element->dph ? str_replace('dic=', 'CZ', strval($element->p_dph)) : '')
            );
            $record->setCompanyName(strval($element->ojm));
            //'adresa' => strval($element->jmn));
            $records[] = $record;
        }
        file_put_contents($cachedFile, serialize($records));

        return $records;
    }
87961
public function getCityData($type, $city, array $param = null)
    {
        return $this->weatherService->getCityData($type, $city, $param);
    }
217358
public function getClientDetails($client_id)
    {
        $result = $this->getObjectByType('client_table',$client_id);

        return is_null($result) ? false : $result;
    }
472339
public function GetID($ID, $DatasetType = FALSE) {
      $Result = $this->GetWhere(array($this->PrimaryKey => $ID))->FirstRow($DatasetType);
      
      $Fields = array('Attributes', 'Data');
      
      foreach ($Fields as $Field) {
         if (is_array($Result)) {
            if (isset($Result[$Field]) && is_string($Result[$Field])) {
               $Val = unserialize($Result[$Field]);
               if ($Val)
                  $Result[$Field] = $Val; 
               else
                  $Result[$Field] = $Val;
            }               
         } elseif (is_object($Result)) {
            if (isset($Result->$Field) && is_string($Result->$Field)) {
               $Val = unserialize($Result->$Field);
               if ($Val)
                  $Result->$Field = $Val;
               else
                  $Result->$Field = NULL;
            }
         }
      }
      
      return $Result;
   }
1030439
public function data($buildId)
    {
        $response = new JsonResponse();
        $build = BuildFactory::getBuildById($buildId);

        if (!$build) {
            $response->setResponseCode(404);
            $response->setContent(array());
            return $response;
        }

        $response->setContent($this->getBuildData($build));
        return $response;
    }
1210689
public function run() {

		$provinceId	= Yii::$app->request->post( 'province-id' );
		$regionId	= Yii::$app->request->post( 'region-id' );
		$name		= Yii::$app->request->post( 'name' );

		$conditions = [ 'provinceId' => $provinceId ];

		if( !empty( $regionId && $regionId > 0 ) ) {

			$conditions[ 'regionId' ] = $regionId;
		}

		$cities = $this->modelService->searchByName( $name, [
			'limit' => 5,
			'conditions' => $conditions,
			'columns' => [ 'id', 'name', 'latitude', 'longitude', 'postal' ]
		]);

		// Trigger Ajax Success
		return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $cities );
	}
232597
function f_bolge_sehirleri(_id) {
        /** @type {LazyLoadingResponse} */
        var sonuc = schema.f_create_default_object(schema.SCHEMA.LAZY_LOADING_RESPONSE);

        return result.dbQ.smembers(result.kp.bolge.ssetSehirleri(_id))
            .then(/**
             *
             * @param {string[]} _sehir_idler
             * @returns {*}
             */
            function (_sehir_idler) {
                if (_sehir_idler && _sehir_idler.length > 0) {
                    var db_sehir = require("./db_sehir");
                    return db_sehir.f_db_sehir_id(_sehir_idler)
                        .then(function (_sehirler) {
                            sonuc.ToplamKayitSayisi = parseInt(_sehirler.length);
                            sonuc.Data = _sehirler;
                            return sonuc;
                        })

                } else {
                    sonuc.ToplamKayitSayisi = 0;
                    sonuc.Data = [];
                    return sonuc;
                }
            })
            .fail(function () {
                l.e("bölge şehirleri çekilemedi");
            });
    }
555784
public static function Using($id = null)
    {
        if (!$id) {
            //初始运行
            self::$using_dbo_id = self::$default_dbo_id;
        } else {
            //切换dbo id
            if ($id != self::$using_dbo_id) {
                self::$using_dbo_id = $id;
            }
        }
        return self::dbo(self::$using_dbo_id);
    }
836281
public function getById($id, $col = null)
    {
        $col = ($col) ?: $this->getPrimaryKey();
        $select = $this->getSelect()->where([$col => $id]);
        $resultSet = $this->fetchResult($select);

        if ($resultSet->count() > 1) {
            $rowSet = [];
            foreach ($resultSet as $row) {
                $rowSet[] = $row;
            }
        } elseif ($resultSet->count() === 1) {
            $rowSet = $resultSet->current();
        } else {
            $rowSet = $this->getModel();
        }

        return $rowSet;
    }
1063165
static public function publicIdDecode($public_id)
    {
        $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet());

        $id = $hashids->decode($public_id);

        if (is_array($id) && isset($id[0]))
            return $id[0];

        return null;
    }
1002701
protected function setStateCity($state_id)
    {
        $this->data_state = $this->state->get($state_id);

        if (empty($this->data_state)) {
            $this->outputHttpStatus(404);
        }
    }
1262120
public function getTerritoryID($id)
	{
		// normalize id
		$id = $this->getCanonicalID($id);
		// find sub tags
		if (($underscorePosition=strpos($id, '_'))!== false)
		{
			$subTag = explode('_', $id);
			// territory sub tags can be distinguished from script sub tags by length
			if (isset($subTag[2]) && strlen($subTag[2])<4)
			{
				$id = $subTag[2];
			}
			elseif (strlen($subTag[1])<4)
			{
				$id = $subTag[1];
			}
			else
			{
				$id = null;
			}
		}
		else
		{
			$id = null;
		}
		return $id;
	}
1161375
public function getArrayData($id)
	{
		$id = intval($id);
		
		# Test id
		if(empty($id))
		{
			$error = new ReceiverError();
			return $error->define('Bad request', 400);
		}
		$request = $this->client->get('/rss-menu-'.$id.'.htm');
		$resource = $request->getResource();
		
		# Test Code
		if(!$resource->code(200))
		{
			$error = new ReceiverError();
			return $error->define('Impossible to contact distant website', 500);
		}
		
		# Get XML
		$content = $resource->getContent();
		$content = mb_convert_encoding($content, mb_internal_encoding(),'CP1252');
		$rss = simplexml_load_string($content, 'SimpleXMLElement', LIBXML_NOCDATA);
		libxml_use_internal_errors(true);
		
		# Get all menu
		$items = $rss->channel[0]->item;
		$menus = array();
		foreach($items as $item){
			$description = trim((string) $item->description);
			if($description != 'Restaurant fermé')
			{
				$menu = array();
				$menu['meals'] = array_values(array_filter(array_map('trim',explode('<br />', $description)), 'strlen'));
				$title = trim((string) $item->title);
				
				# Date Calcul
				$dateArray = explode(' ', $title);
				$dateTime = new \DateTime();
				$date = array_map('trim',explode('/', $dateArray[2]));
				$dateTime->setDate($date[2], $date[1], $date[0]);
				$start = clone $dateTime;
				$end = clone $dateTime;
				if($dateArray[1] == 'midi')
				{
					$start->setTime(11, 30);
					$end->setTime(13, 15);
				}
				else
				{
					$start->setTime(18, 30);
					$end->setTime(19, 45);
				}
				$menu['start'] = $start->getTimestamp();
				$menu['end'] = $end->getTimestamp();
				$menu['rss'] = array
				(
					'title' => $title,
					'link' => trim((string) $item->link),
					'pubDate' => trim((string) $item->pubDate)
				);
				$menus[] = $menu;
			}
		}
		return $menus;
	}
740478
public function getIdByName($city)
    {
        // 如果是特殊城市,如上海市,转换为上海市"市辖区"的ID
        if (isset($this->cityIds[$city])) {
            return $this->cityIds[$city];
        }

        $areaId = wei()->area()->select('id')->fetchColumn(['name' => $city]);
        if ($areaId) {
            return $areaId;
        }

        return false;
    }
1174045
public function city()
	{
		$requestParams = $this->initRequestParams('city');
		$this->request('city', $requestParams);

		return empty($this->error);
	}