我想从我的表中删除这是函数,
function deleteFromTable($table, $file_upload_id, $dbh) {
$deleteTable = $dbh->prepare("DELETE FROM ".$table." WHERE upload_id = ?");
$deleteTable->execute(array($file_upload_id));
$deleted = $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print_r($deleted);exit;
}
deleteFromTable('reimbursment_id', '76', $dbh);
我没有收到错误,也没有从我的桌子上删除任何东西;但是当我试图在没有变量的情况下它完美地运行时,这段代码有什么问题吗?
答案 0 :(得分:-1)
试试这样的事情吧。不要认为准备喜欢变量
$sth = $dbh->prepare('DELETE FROM :table WHERE id = :id');
$sth->execute(array(':table' => $table, ':id' => $file_upload_id));
如果完成这项工作,请尝试回显sql并在phpmyadmin或mysql终端中尝试,如果有的话。