2 回答
TA贡献1829条经验 获得超7个赞
Delete_Lease 缺少绑定和执行以及要删除的租约 ID。用于删除的 sql 不需要“*”。
属性.mc.php
public function Delete_Lease($db, $leaseid) {
$stmt = $db->prepare(
"DELETE FROM
for_lease
WHERE
leaseid = :leaseid "
);
$stmt->execute(['leaseid' => $leaseid]);
}
for_lease.vc.php
if (isset($_GET['delete'])){
$rowProperty = $mcProperty->Delete_Lease($db, $_GET['leaseid']);
}
修复覆盖 for_lease.php 中删除 ID 的删除按钮
<td>
<a href="for_lease.php?leaseid=<?php echo($rowProperty['leaseid']); ?>" onclick="return confirm('Are you sure?');"><input type="submit" class="btn bg-color-red color-white form-control" name="delete" value="DELETE"></a>
</td>
TA贡献2003条经验 获得超2个赞
你不是在执行 sql 语句,你只是在准备它。此外,您的代码设置方式,您需要将 传递leaseid给您的删除功能。
试试这个。
for_lease.vc.php
<?php
$routePath = "../";
require_once($routePath . "_config/db.php");
$dbConfig = new config_db();
$db = $dbConfig->init();
require_once($routePath . "_mc/Property.mc.php");
$mcProperty = new Property_MC();
$lstProperty = $mcProperty->SelectObj_ByLeaseId($db);
if (isset($_GET['delete'])){
$rowProperty = $mcProperty->Delete_Lease($db, $_GET['delete']);
}
?>
属性.mc.php
public function Delete_Lease($db, $leaseid) {
$stmt = $db->prepare(
" DELETE FROM
for_lease
WHERE
leaseid = :leaseid "
);
$stmt->execute([':leaseid' => $leaseid]);
}
- 2 回答
- 0 关注
- 255 浏览
添加回答
举报