* @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_PS_VERSION_')) exit; function upgrade_module_1_7_7($object) { $cols = array( 'start_day' => array('exist' => false, 'sql' => 'ALTER TABLE `'._DB_PREFIX_.'advice` ADD `start_day` INT NULL DEFAULT 0 '), 'stop_day' => array('exist' => false, 'sql' => 'ALTER TABLE `'._DB_PREFIX_.'advice` ADD `stop_day` INT NULL DEFAULT 0 '), 'start_date' => array('exist' => false, 'sql' => 'ALTER TABLE `'._DB_PREFIX_.'advice` DROP `start_date`'), 'stop_date' => array('exist' => false, 'sql' => 'ALTER TABLE `'._DB_PREFIX_.'advice` DROP `stop_date`'), ); $columns = Db::getInstance()->executeS('SHOW COLUMNS FROM `'._DB_PREFIX_.'advice` '); foreach ($columns as $c) if (in_array($c['Field'], array_keys($cols))) $cols[$c['Field']]['exist'] = true; foreach ($cols as $name => $co) if (in_array($name, array('start_day', 'stop_day'))) { if (!$co['exist']) Db::getInstance()->execute($co['sql']); } elseif ($co['exist']) Db::getInstance()->execute($co['sql']); return true; }