public function execute() { try { if ($id = waRequest::post('id')) { $price_model = new shopPricePluginModel(); $price_model->deleteById($id); $sql = "ALTER TABLE `shop_product_skus` DROP `price_plugin_" . $price_model->escape($id) . "`"; $price_model->query($sql); } } catch (Exception $e) { $this->setError($e->getMessage()); } }
public function execute() { try { $price_model = new shopPricePluginModel(); $price = waRequest::post('price', array()); if (!empty($price['id'])) { $price_model->updateById($price['id'], $price); } else { $id = $price_model->insert($price); $price['id'] = $id; $sql = "ALTER TABLE `shop_product_skus` ADD `price_plugin_{$id}` DECIMAL( 15, 4 ) NOT NULL"; $price_model->query($sql); } $this->response['price'] = $price_model->getById($price['id']); } catch (Exception $e) { $this->setError($e->getMessage()); } }
<?php $price_model = new shopPricePluginModel(); $prices = $price_model->getAll(); try { foreach ($prices as $price) { $sql = "ALTER TABLE `shop_product_skus` DROP `price_plugin_" . $price_model->escape($price['id']) . "`"; $price_model->query($sql); $price_model->deleteById($price['id']); } } catch (waDbException $e) { }