Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/country_states_helper.php
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Returns countries, that have states | * Returns countries, that have states | ||||
* | * | ||||
* @return Array | * @return Array | ||||
*/ | */ | ||||
function getCountriesWithStates() | function getCountriesWithStates() | ||||
{ | { | ||||
static $cache = null; | $cache_key = 'countries_with_states[%CountryStateSerial%]'; | ||||
$cache_value = $this->Application->getCache($cache_key); | |||||
if (!isset($cache)) { | if ( $cache_value === false ) { | ||||
$table_name = $this->Application->getUnitOption('country-state', 'TableName'); | $table_name = $this->Application->getUnitOption('country-state', 'TableName'); | ||||
$sql = 'SELECT DISTINCT cname.IsoCode, cid.StateCountryId | $sql = 'SELECT DISTINCT cname.IsoCode, cid.StateCountryId | ||||
FROM ' . $table_name . ' cid | FROM ' . $table_name . ' cid | ||||
JOIN ' . $table_name . ' cname ON cname.CountryStateId = cid.StateCountryId | JOIN ' . $table_name . ' cname ON cname.CountryStateId = cid.StateCountryId | ||||
WHERE cid.StateCountryId IS NOT NULL'; | WHERE cid.StateCountryId IS NOT NULL'; | ||||
$cache = $this->Conn->GetCol($sql, 'StateCountryId'); | $cache_value = $this->Conn->GetCol($sql, 'StateCountryId'); | ||||
$this->Application->setCache($cache_key, $cache_value); | |||||
} | } | ||||
return $cache; | return $cache_value; | ||||
} | } | ||||
/** | /** | ||||
* Checks, that country with given 3symbol ISO code has states | * Checks, that country with given 3symbol ISO code has states | ||||
* | * | ||||
* @param string $country_code | * @param string $country_code | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines |