簡體   English   中英

PHP Mysql不刪除行

[英]PHP Mysql not Deleting rows

試圖能夠從數據庫中刪除一些行,但語句未返回任何錯誤,並且如果我在phpmyadmin中運行查詢,則實際上會刪除該記錄。 同樣執行SELECT語句也沒有問題。

$ oId參數具有int值

$stmt =  $this->db->prepare('DELETE FROM tbl_bdays WHERE uniqueId = ?');
$stmt->bind_param("i", $oId);
$stmt->execute();
$stmt->close();

如果表名從字面上看是table ,則它是錯誤的,因為table保留字

如果您確實無法更改名稱,則需要用反引號將其包裝:

DELETE FROM `table` WHERE uniqueId = ?

您沒有錯誤檢查,應該檢查方法中的每個步驟是否有錯誤。 嘗試這個:

$stmt = $this->db->prepare('DELETE FROM tbl_bdays WHERE uniqueId = ?');
if ( ! $stmt) die('Error whilst preparing: '.$this->db->error);
if ( ! $stmt->bind_param("i", $oId)) die('Error whilst binding: '.$this->db->error);
if ( ! $stmt->execute()) die('Error whilst executing: '.$this->db->error);
$stmt->close();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM