// A few dozens queries less on every pages...

This commit is contained in:
dMetzger
2012-02-09 17:15:05 +00:00
parent c7d5e920a6
commit e102ae2928
4 changed files with 64 additions and 45 deletions
+10 -9
View File
@@ -508,20 +508,21 @@ class AddressFormatCore extends ObjectModel
public function getFormat($id_country)
{
$out = $this->_getFormatDB($id_country);
if (strlen(trim($out)) == 0)
if (empty($out))
$out = $this->_getFormatDB(Configuration::get('PS_COUNTRY_DEFAULT'));
return $out;
}
protected function _getFormatDB($id_country)
{
$result = Db::getInstance()->getRow('
SELECT format
FROM `'._DB_PREFIX_.$this->def['table'].'`
WHERE `id_country` = '.(int)($id_country));
return isset($result['format']) ? trim($result['format']) : '';
if (!Cache::isStored('AddressFormat::_getFormatDB'.$id_country))
{
$format = Db::getInstance()->getValue('
SELECT format
FROM `'._DB_PREFIX_.$this->def['table'].'`
WHERE `id_country` = '.(int)$id_country);
Cache::store('AddressFormat::_getFormatDB'.$id_country, trim($format));
}
return Cache::retrieve('AddressFormat::_getFormatDB'.$id_country);
}
}