SQL Delete语句未执行

时间:2019-05-27 01:00:37

标签: php sql sql-delete

我有三个相互连接的文件,我的问题是我的删除功能似乎无法正常工作。我想知道“公共函数Delete_Lease($ db){”中缺少的内容,下面显示了代码。基本上,我每个人都使用a来显示表格,编辑工作没有问题,但是删除仅停留在同一页面上,没有任何作用。

表名: for_lease

值::租约ID,租赁类型,租赁名称,租赁地址,租赁价格,租赁条件,租赁描述,精选照片,创建日期

table for_lease.php

<?php
  session_start();
  require_once('for_lease.vc.php');
?>

 <?php foreach($lstProperty as $rowProperty) { ?>
       <tr align="center">
         <td>
          <a href="for_lease_edit.php?i=<?php echo($rowProperty['leaseid']); ?>"><input type="submit" class="btn bg-color-blue color-white form-control" name="edit" value="EDIT"></a>
         </td>

         <td>
           <?php
             echo($rowProperty['lease_name']);
           ?>
         </td>

         <td>
           <?php
             echo($rowProperty['lease_address']);
           ?>
         </td>

         <td>
           <?php
             echo($rowProperty['lease_type']);
           ?>
         </td>

         <td>
           <?php
             echo 'PHP'.' '.number_format(($rowProperty['lease_price']));
           ?>
         </td>

         <td>
           <?php
             echo($rowProperty['lease_condition']);
           ?>
         </td>

         <td>
           <?php
             echo( date("Y-m-d", strtotime($rowProperty['createddate']) ));
           ?>
         </td>

         <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>
       </tr>
 <?php } ?>

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']);
  }
    ?>

Property.mc.php

<?php
Class Property_MC {

  public function SelectObj_ByLeaseId($db) {
  $stmt = $db->prepare(
    " SELECT leaseid, lease_type, lease_name, lease_address, lease_price, lease_condition, lease_description, createddate
      FROM for_lease"
  );

  $stmt->execute();
  $row = $stmt->fetchAll(PDO::FETCH_ASSOC);

  return $row;
  }

  public function Delete_Lease($db, $leaseid) {
      $stmt = $db->prepare(
          "DELETE FROM
          for_lease
          WHERE
          leaseid = :leaseid "
          );
      $stmt->execute(['leaseid' => $leaseid]);
  }

0 个答案:

没有答案