// Deleted carriers are now properly removed from the table warehouse_carrier

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10107 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
bMancone
2011-11-14 15:44:26 +00:00
parent 04e40cbb73
commit 726a53c490
2 changed files with 26 additions and 2 deletions
+17 -1
View File
@@ -182,6 +182,20 @@ class WarehouseCore extends ObjectModel
Db::getInstance()->autoExecute(_DB_PREFIX_.'warehouse_carrier', $row_to_insert, 'INSERT');
}
/**
* For a given carrier, removes it from the warehouse/carrier association
* If $id_warehouse is set, it only removes the carrier for this warehouse
* @param int $id_carrier
* @param int $id_warehouse optional
*/
public static function removeCarrier($id_carrier, $id_warehouse = null)
{
Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'warehouse_carrier
WHERE id_carrier = '.(int)$id_carrier.
($id_warehouse ? ' AND id_warehouse = '.(int)$id_warehouse : ''));
}
/**
* Checks if a warehouse is empty - i.e. holds no stock
*
@@ -315,7 +329,9 @@ class WarehouseCore extends ObjectModel
FROM '._DB_PREFIX_.'stock s
WHERE s.id_warehouse = '.(int)$this->id;
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
return ($res ? $res : 0);
}
/**