From 5fc2d5fe34457b4fa96cb4697ec01e29954d00d3 Mon Sep 17 00:00:00 2001 From: bMancone Date: Mon, 10 Oct 2011 08:43:56 +0000 Subject: [PATCH] // StockWarehouse updated git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9170 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/stock/StockWarehouse.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/classes/stock/StockWarehouse.php b/classes/stock/StockWarehouse.php index 43a7b59e4..12d0fd5ab 100644 --- a/classes/stock/StockWarehouse.php +++ b/classes/stock/StockWarehouse.php @@ -30,6 +30,7 @@ */ class StockWarehouseCore extends ObjectModel { + public $id; public $id_address; public $reference; public $name; @@ -73,7 +74,7 @@ class StockWarehouseCore extends ObjectModel } /** - * For the current warehouse, gets its shops ids list + * For the current warehouse, gets the shops it is associated to * * @return array */ @@ -87,7 +88,7 @@ class StockWarehouseCore extends ObjectModel } /** - * For the current warehouse, sets its shop ids list + * For the current warehouse, sets the shops it is associated to * * @param array $id_shop_list List of shop ids */ @@ -97,17 +98,22 @@ class StockWarehouseCore extends ObjectModel foreach ($id_shop_list as $id_shop) $row_to_insert = array($this->reference => $this->id, 'id_shop' => $id_shop); - Db::getInstance()->ExecuteS('DELETE INTO `warehouse_shop` ws WHERE ws.'.$this->identifier.' = '.(int)$this->id); - Db::getInstance()->autoExecute('warehouse_shop', $row_to_insert, 'INSERT'); + Db::getInstance(_PS_USE_SQL_SLAVE_)->Execute('DELETE INTO `warehouse_shop` ws WHERE ws.'.$this->identifier.' = '.(int)$this->id); + Db::getInstance(_PS_USE_SQL_SLAVE_)->autoExecute('warehouse_shop', $row_to_insert, 'INSERT'); } /** * For a given warehouse, checks if it exists * - * @param $id_warehouse warehouse identifier + * @param int $id_warehouse + * @return bool */ public static function exists($id_warehouse) { - return (bool)Db::getInstance()->getValue('SELECT count(*) INTO `warehouse` w WHERE w.id_warehouse = '.(int)$id_warehouse); + return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' + SELECT w.id_warehouse + FROM `warehouse` w + WHERE w.id_warehouse = '.(int)$id_warehouse.' + LIMIT 1'); } } \ No newline at end of file