[*] FO : lots of performance improvements (removed or merged useless SQL queries)

This commit is contained in:
Damien Metzger
2013-07-19 10:58:51 +02:00
parent 219ec6e8be
commit bd4ece095b
4 changed files with 74 additions and 48 deletions
+16 -9
View File
@@ -113,19 +113,26 @@ class HookCore extends ObjectModel
if (!Validate::isHookName($hook_name))
return false;
$cache_id = 'hook_idbyname_'.$hook_name;
$cache_id = 'hook_idsbyname';
if (!Cache::isStored($cache_id))
{
$retro_hook_name = Hook::getRetroHookName($hook_name);
Cache::store($cache_id, Db::getInstance()->getValue('
SELECT `id_hook`
FROM `'._DB_PREFIX_.'hook`
WHERE `name` = \''.pSQL($hook_name).'\'
OR `name` = \''.pSQL($retro_hook_name).'\'
'));
// Get all hook ID by name and alias
$hook_ids = array();
$result = Db::getInstance()->ExecuteS('
SELECT `id_hook`, `name`
FROM `'._DB_PREFIX_.'hook`
UNION
SELECT `id_hook`, ha.`alias` as name
FROM `ps_hook_alias` ha
INNER JOIN `ps_hook` h ON ha.name = h.name');
foreach ($result as $row)
$hook_ids[$row['name']] = $row['id_hook'];
Cache::store($cache_id, $hook_ids);
}
else
$hook_ids = Cache::retrieve($cache_id);
return Cache::retrieve($cache_id);
return (isset($hook_ids[$hook_name]) ? $hook_ids[$hook_name] : false);
}
/**