use pt\framework\debug\console as debug; use pt\framework\template; use pt\framework\db; use pt\tool\filter; // include your project common functions. // this is a demo that have some useful functions. include COMMON_PATH . 'web_func.php'; include COMMON_PATH . 'hook.inc.php'; // User id if (empty($_SESSION['uid'])) { json_return(null, 1, 'Please Login.'); } $uid = (int) $_SESSION['uid']; // set timeout seconds set_time_limit(config('web.refresh_timeout')); $db = db::init(); if (!empty($_POST['id'])) { // Get product data from db $product = $db->prepare("SELECT * FROM `a_good` WHERE `id`=:id AND `user`=:uid")->execute(array(':id' => $_POST['id'], ':uid' => $uid)); if (!$product) { json_return(null, 1, 'Not Found any product.'); } $product = $product[0]; } else { if (!empty($_POST['url'])) { // Request a url for create a new product. $url = trim($_POST['url']); $pos = strpos($url, '/dp/B'); $len = 4; if ($pos === false) { $pos = strpos($url, '/gp/product/B');
static function delete($product) { $db = db::init(); $rs = $db->prepare("DELETE FROM `a_price` WHERE `product`=:id")->execute(array(':id' => $product)); if (false === $rs) { $db->rollback(); json_return(null, 2, 'Operation failed.'); } }