// cache system on getIsoById

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14420 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
fBrignoli
2012-04-03 08:39:42 +00:00
parent 98cd41799f
commit 89fd4903ee
+10 -6
View File
@@ -92,6 +92,8 @@ class CountryCore extends ObjectModel
) )
); );
protected static $cache_iso_by_id = array();
protected $webserviceParameters = array( protected $webserviceParameters = array(
'objectsNodeName' => 'countries', 'objectsNodeName' => 'countries',
'fields' => array( 'fields' => array(
@@ -208,13 +210,15 @@ class CountryCore extends ObjectModel
*/ */
public static function getIsoById($id_country) public static function getIsoById($id_country)
{ {
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' if (!isset(Country::$cache_iso_by_id[$id_country]))
SELECT `iso_code` {
FROM `'._DB_PREFIX_.'country` Country::$cache_iso_by_id[$id_country] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
WHERE `id_country` = '.(int)$id_country SELECT `iso_code`
); FROM `'._DB_PREFIX_.'country`
WHERE `id_country` = '.(int)($id_country));
}
return $result['iso_code']; return Country::$cache_iso_by_id[$id_country];
} }
/** /**