[*] FO : a few more SQL improvements
This commit is contained in:
@@ -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
|
||||
if (!isset($cookie->id_connections) || !strstr(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', Tools::getHttpHost(false, false)))
|
||||
$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)
|
||||
$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'))
|
||||
return array('id_page' => $id_page);
|
||||
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class HookCore extends ObjectModel
|
||||
|
||||
public function add($autodate = true, $null_values = false)
|
||||
{
|
||||
Cache::clean('hook_idbyname_'.$this->name);
|
||||
Cache::clean('hook_idsbyname');
|
||||
return parent::add($autodate, $null_values);
|
||||
}
|
||||
|
||||
|
||||
+16
-19
@@ -143,22 +143,21 @@ class ShopUrlCore extends ObjectModel
|
||||
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)
|
||||
{
|
||||
if (!Validate::isUnsignedId($id_shop))
|
||||
return false;
|
||||
|
||||
ShopUrl::getMainShopDomain($id_shop);
|
||||
ShopUrl::getMainShopDomainSSL($id_shop);
|
||||
if (!self::$main_domain_ssl || !self::$main_domain || $id_shop !== null)
|
||||
{
|
||||
$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()
|
||||
@@ -167,17 +166,15 @@ class ShopUrlCore extends ObjectModel
|
||||
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)
|
||||
{
|
||||
if (!self::$main_domain_ssl || $id_shop !== null)
|
||||
{
|
||||
$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);
|
||||
}
|
||||
ShopUrl::cacheMainDomainForShop($id_shop);
|
||||
return self::$main_domain_ssl;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user