本文整理汇总了PHP中product::deleteProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP product::deleteProduct方法的具体用法?PHP product::deleteProduct怎么用?PHP product::deleteProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::deleteProduct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteProduct_Action
function deleteProduct_Action()
{
$product_id = $_GET['product_id'];
$list_url = 'http://' . HOST . '/' . APPLICATION . '/index.php?page=home';
$product = new product();
$result = $product->deleteProduct($product_id);
header("Location: {$list_url}");
}
示例2: echoResponse
$app->get('/products', function () {
$product = new product();
$response = $product->getAllProduct();
echoResponse(200, $response);
});
$app->post('/products', function () use($app) {
$product = new product();
$data = json_decode($app->request->getBody(), TRUE);
$id = $product->AddProduct($data);
echoResponse(200, $id);
});
$app->put('/products/:id', function ($id) use($app) {
$product = new product();
$data = json_decode($app->request->getBody(), TRUE);
$result = $product->updateProduct($id, $data);
// $rows["message"] = "Product information updated successfully.";
echoResponse(200, $result);
});
$app->delete('/products/:id', function ($id) {
$product = new product();
$id = $product->deleteProduct($id);
echoResponse(200, $id);
});
function echoResponse($status_code, $response)
{
global $app;
$app->status($status_code);
$app->contentType('application/json');
echo json_encode($response, JSON_NUMERIC_CHECK);
}
$app->run();
示例3: elseif
} elseif (isset($_POST['action']) && $_POST['action'] == 'update') {
$file = $_FILES;
$data = $_POST['data']['Item'];
if (isset($file['name'])) {
$data['image'] = $file['name'];
} else {
$data['image'] = '';
}
if ($product->updateProduct($data)) {
$_SESSION['message'] = 'Product has been updated successfully.';
header('Location: ' . FRONTEND . 'inventory.php');
exit;
}
} elseif (isset($_GET['action']) && $_GET['action'] == 'delete') {
$id = $_GET['id'];
if ($product->deleteProduct($id)) {
$_SESSION['message'] = 'Product has been deleted successfully.';
header('Location: ' . FRONTEND . 'inventory.php');
exit;
}
} elseif (isset($_GET['action']) && $_GET['action'] == 'search') {
$keyword = $_POST['keywords'];
$products = $product->getSearchProducts($keyword);
$smarty->assign('productcount', count($products));
$smarty->assign('products', $products);
$smarty->assign('content', $smarty->fetch('product.tpl'));
} else {
$page = 1;
if (isset($_GET['page'])) {
$page = $_GET['page'];
}