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

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@13197 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-02-09 17:15:05 +00:00
parent 314abcd76c
commit a056a78177
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);
}
}