我尝试删除数据....但它捕获了此错误....当我尝试使用mvc样式对php进行新操作时....当我尝试使用printR ist返回字符串而不是整数进行调试时....
未捕获的PDOException:SQLSTATE [22P02]:无效的文本表示形式:7 错误:整数:“ Compliance”中的输入语法无效 C:\ xampp \ htdocs \ ims \ app \ models \ CMP999 \ CMP999.php:119堆栈跟踪:#0 C:\ xampp \ htdocs \ ims \ app \ models \ CMP999 \ CMP999.php(119): PDOStatement-> execute()#1 C:\ xampp \ htdocs \ ims \ app \ controllers \ Compliance \ CMP999Controller.php(150): CMP999-> deleteData('Compliance')#2 C:\ xampp \ htdocs \ ims \ app \ core \ App.php(146): CMP999Controller-> delete('Compliance','CMP999','delete','1')#3 C:\ xampp \ htdocs \ ims \ public \ index.php(7):App-> __ construct()#4 {main} 在第119行的C:\ xampp \ htdocs \ ims \ app \ models \ CMP999 \ CMP999.php中抛出
// CMP999.php模型
public function deleteData($stud_id) {
// $sql = "DELETE FROM test WHERE id = :id";
//$stmt = $this->pdo->prepare($sql);
//$stmt->execute([':id' => $id]);
$count2 = $this->pdo->prepare("DELETE FROM test WHERE stud_id=:stud_id");
$count2->bindParam("stud_id", $stud_id);
$count2->execute();
return $count2;
}
// CMP999Controller.php
public function delete($stud_id) {
// print_r($stud_id);
//die();
if ($this->model('CMP999')->deleteData($stud_id)) {
header('Location: ' . BASE_URL . 'Compliance/CMP999');
exit();
}
}
// index.php,点击删除按钮
<a href="<?= BASE_URL; ?>Compliance/CMP999/delete/<?= $column['stud_id']; ?>" class="btn btn-danger float-right ml-3" onclick=" return confirm('Are you Sure?');" ><img src="<?= BASE_URL ?>images/pemadam.png" alt="STALIN" width="20"> </a>
我希望我可以在单击按钮时删除数据...