我正在创建商店并添加要存储的项目,然后尝试删除商店,并且项目属于该商店。 它可以完美地工作(如果有属于商店的商品)。 但是如果没有项目属于商店,那么它不会删除商店。 stil显示存储在数据库中。 我正在本地主机上工作
如果有人想尝试,我会先添加总代码。
代码如下:
if (isset($_GET['store_id']) && is_numeric($_GET['store_id'])){
$storeid = filterString($_GET['store_id']);
$bringa = bring_product_image($storeid);
foreach($bringa as $row);
$oldimage = "../images/items/".$row['item_image'];
$bring = bringstoreimage($storeid);
foreach($bring as $row);
$storeoldimage = "../images/stores/".$row['store_image'];
$stmt = $pdo->prepare('DELETE c,p FROM stores c
INNER JOIN products p ON c.store_id = p.storeid
WHERE store_id = :store_id
');
$del = $stmt->execute(array(':store_id' =>$storeid));
if($del){
unlink($storeoldimage);
unlink($oldimage);
$_SESSION['message'] = "Store deleted!";
header("location: success.php");
exit();
}else{
$_SESSION['message'] = "Something went wrong!";
header("location: error.php");
exit();
}
}
这是我遇到问题的代码部分。
$stmt = $pdo->prepare('DELETE c,p FROM stores c
INNER JOIN products p ON c.store_id = p.storeid
WHERE store_id = :store_id
');
答案 0 :(得分:0)
尝试使用左联接。
WebMock::NetConnectNotAllowedError