[*] FO : a few more SQL improvements

This commit is contained in:
Damien Metzger committed 2013-07-19 11:29:18 +02:00
1 parent bd4ece095b
commit 989dafce21
3 files changed
+21 -20

No files matched your search

+4
View File
@@ -82,8 +82,12 @@ class ConnectionCore extends ObjectModel
// The connection is created if it does not exist yet and we get the current page id // The connection is created if it does not exist yet and we get the current page id
if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false))) if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
$id_page = Connection::setNewConnection($cookie); $id_page = Connection::setNewConnection($cookie);
// If we do not track the pages, no need to get the page id
if (!Configuration::get('PS_STATSDATA_PAGESVIEWS') && !Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array();
if (!isset($id_page) || !$id_page) if (!isset($id_page) || !$id_page)
$id_page = Page::getCurrentId(); $id_page = Page::getCurrentId();
// If we do not track the page views by customer, the id_page is the only information needed
if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) if (!Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS'))
return array('id_page' => $id_page); return array('id_page' => $id_page);
+1 -1
View File
@@ -83,7 +83,7 @@ class HookCore extends ObjectModel
public function add($autodate = true, $null_values = false) public function add($autodate = true, $null_values = false)
{ {
Cache::clean('hook_idbyname_'.$this->name); Cache::clean('hook_idsbyname');
return parent::add($autodate, $null_values); return parent::add($autodate, $null_values);
} }
+16 -19
View File
@@ -143,22 +143,21 @@ class ShopUrlCore extends ObjectModel
return Db::getInstance()->getValue($sql); return Db::getInstance()->getValue($sql);
} }
public static function getMainShopDomain($id_shop = null)
{
if (!self::$main_domain || $id_shop !== null)
self::$main_domain = Db::getInstance()->getValue('SELECT domain
FROM '._DB_PREFIX_.'shop_url
WHERE main=1 AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id));
return self::$main_domain;
}
public static function cacheMainDomainForShop($id_shop) public static function cacheMainDomainForShop($id_shop)
{ {
if (!Validate::isUnsignedId($id_shop)) if (!Validate::isUnsignedId($id_shop))
return false; return false;
ShopUrl::getMainShopDomain($id_shop); if (!self::$main_domain_ssl || !self::$main_domain || $id_shop !== null)
ShopUrl::getMainShopDomainSSL($id_shop); {
$row = Db::getInstance()->getRow('
SELECT domain, domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id));
self::$main_domain = $row['domain'];
self::$main_domain_ssl = $row['domain_ssl'];
}
} }
public static function resetMainDomainCache() public static function resetMainDomainCache()
@@ -167,17 +166,15 @@ class ShopUrlCore extends ObjectModel
self::$main_domain_ssl = null; self::$main_domain_ssl = null;
} }
public static function getMainShopDomain($id_shop = null)
{
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain;
}
public static function getMainShopDomainSSL($id_shop = null) public static function getMainShopDomainSSL($id_shop = null)
{ {
if (!self::$main_domain_ssl || $id_shop !== null) ShopUrl::cacheMainDomainForShop($id_shop);
{
$sql = 'SELECT domain_ssl
FROM '._DB_PREFIX_.'shop_url
WHERE main = 1
AND id_shop = '.($id_shop !== null ? (int)$id_shop : Context::getContext()->shop->id);
self::$main_domain_ssl = Db::getInstance()->getValue($sql);
}
return self::$main_domain_ssl; return self::$main_domain_ssl;
} }
} }