[*] CORE : Remove duplicate SQL queries

This commit is contained in:
gRoussac
2013-11-11 13:41:23 +01:00
parent de404706d9
commit a7869a1f06
22 changed files with 507 additions and 322 deletions
+14 -8
View File
@@ -171,6 +171,8 @@ class WishList extends ObjectModel
*/
public static function getByIdCustomer($id_customer)
{
if (!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
if (Shop::getContextShopID())
$shop_restriction = 'AND id_shop = '.(int)Shop::getContextShopID();
elseif (Shop::getContextShopGroupID())
@@ -178,14 +180,18 @@ class WishList extends ObjectModel
else
$shop_restriction = '';
if (!Validate::isUnsignedId($id_customer))
die (Tools::displayError());
return (Db::getInstance()->executeS('
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
FROM `'._DB_PREFIX_.'wishlist` w
WHERE `id_customer` = '.(int)($id_customer).'
'.$shop_restriction.'
ORDER BY w.`name` ASC'));
$cache_id = __CLASS__.__FUNCTION__.(int)$id_customer.'-'.(int)Shop::getContextShopID().'-'.(int)Shop::getContextShopGroupID();
if (!Cache::isStored($cache_id))
{
$result = Db::getInstance()->executeS('
SELECT w.`id_wishlist`, w.`name`, w.`token`, w.`date_add`, w.`date_upd`, w.`counter`
FROM `'._DB_PREFIX_.'wishlist` w
WHERE `id_customer` = '.(int)($id_customer).'
'.$shop_restriction.'
ORDER BY w.`name` ASC');
Cache::store($cache_id, $result);
}
return Cache::retrieve($cache_id);
}
public static function refreshWishList($id_wishlist)