From ff94cd727963f94fc9a30a9d807bf06c3e6f1de3 Mon Sep 17 00:00:00 2001 From: mMarinetti Date: Thu, 7 Jun 2012 09:52:07 +0000 Subject: [PATCH] // add missings columns id_shop and id_group_shop in statssearch --- .../php/p15013_add_missing_columns.php | 45 +++++++++++++++++++ install-dev/upgrade/sql/1.5.0.13.sql | 5 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 install-dev/upgrade/php/p15013_add_missing_columns.php diff --git a/install-dev/upgrade/php/p15013_add_missing_columns.php b/install-dev/upgrade/php/p15013_add_missing_columns.php new file mode 100644 index 000000000..1d5d874d7 --- /dev/null +++ b/install-dev/upgrade/php/p15013_add_missing_columns.php @@ -0,0 +1,45 @@ + +* @copyright 2007-2012 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +function p15013_add_missing_columns() +{ + $errors = array(); + $db = Db::getInstance(); + $id_module = $db->getValue('SELECT id_module FROM `'._DB_PREFIX_.'module` WHERE name="statssearch"'); + + if ($id_module) + { + if (!Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'statssearch` + ADD `id_group_shop` INT(10) NOT NULL default "1" AFTER id_statssearch, + ADD `id_shop` INT(10) NOT NULL default "1" AFTER id_statssearch')) + { + $errors[] = $db->getMsgError(); + } + } + if (count($errors)) + return array('error' => 1, 'msg' => implode(',', $errors)) ; +} diff --git a/install-dev/upgrade/sql/1.5.0.13.sql b/install-dev/upgrade/sql/1.5.0.13.sql index a902ced76..83f96c5a2 100644 --- a/install-dev/upgrade/sql/1.5.0.13.sql +++ b/install-dev/upgrade/sql/1.5.0.13.sql @@ -44,4 +44,7 @@ UPDATE `PREFIX_employee` UPDATE `PREFIX_category_shop` cs SET `position` = (SELECT `position` FROM `PREFIX_category` c WHERE cs.`id_category` = c.`id_category`); -ALTER TABLE `PREFIX_stock_available` CHANGE `out_of_stock` `out_of_stock` INT(2) UNSIGNED NOT NULL DEFAULT '0'; \ No newline at end of file +ALTER TABLE `PREFIX_stock_available` CHANGE `out_of_stock` `out_of_stock` INT(2) UNSIGNED NOT NULL DEFAULT '0'; + +/* PHP:p15013_add_missing_columns(); */; +