From 5d5eeba04e7fe7e176ffe60c798fc0d93f764861 Mon Sep 17 00:00:00 2001 From: lBrieu Date: Wed, 31 Aug 2011 08:27:58 +0000 Subject: [PATCH] --- classes/Notification.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/Notification.php b/classes/Notification.php index ebea9fba8..c5a14a4ac 100644 --- a/classes/Notification.php +++ b/classes/Notification.php @@ -43,7 +43,7 @@ class Notification public function getLastElements() { $notifications = array(); - $employee_infos = Db::getInstance()->getRow(' + $employee_infos = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow(' SELECT id_last_order, id_last_message, id_last_customer FROM `'._DB_PREFIX_.'employee` WHERE `id_employee` = '.(int)$this->context->employee->id); @@ -67,16 +67,16 @@ class Notification if ($type == 'order' || $type == 'message') $sql = 'SELECT id_order - FROM `'._DB_PREFIX_.(($type == 'order') ? $type.'s' : $type).'` - WHERE `id_'.$type.'` > '.$id_last_element.' - ORDER BY `id_'.$type.'` DESC LIMIT 5'; + FROM `'._DB_PREFIX_.(($type == 'order') ? pSQL($type).'s' : pSQL($type)).'` + WHERE `id_'.pSQL($type).'` > '.(int)$id_last_element.' + ORDER BY `id_'.pSQL($type).'` DESC LIMIT 5'; else - $sql = 'SELECT id_'.$type.' - FROM `'._DB_PREFIX_.$type.'` - WHERE `id_'.$type.'` > '.$id_last_element.' - ORDER BY `id_'.$type.'` DESC LIMIT 5'; + $sql = 'SELECT id_'.pSQL($type).' + FROM `'._DB_PREFIX_.pSQL($type).'` + WHERE `id_'.pSQL($type).'` > '.(int)$id_last_element.' + ORDER BY `id_'.pSQL($type).'` DESC LIMIT 5'; - return Db::getInstance()->ExecuteS($sql); + return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql); } /** @@ -92,8 +92,8 @@ class Notification // We update the last item viewed return Db::getInstance()->Execute(' UPDATE `'._DB_PREFIX_.'employee` - SET `id_last_'.$type.'` = (SELECT MAX(`id_'.$type.'`) - FROM `'._DB_PREFIX_.(($type == 'order') ? $type.'s' : $type).'`) + SET `id_last_'.pSQL($type).'` = (SELECT MAX(`id_'.$type.'`) + FROM `'._DB_PREFIX_.(($type == 'order') ? pSQL($type).'s' : pSQL($type)).'`) WHERE `id_employee` = '.(int)$this->context->employee->id); else return false;