简单DELETE php pdo查询

时间:2014-03-21 16:20:52

标签: php sql sql-delete

我想删除数据,但有多个条件,所以我写这个:

$STH = $DBH->prepare("DELETE FROM track_aktivnosti WHERE (ID,ajdi), VALUES(:id,:ajdi)");

            $STH->bindParam(':id', $_POST['vrednostid']);
        $STH->bindParam(':ajdi', $_POST['ajdi']);

但我有错误是声明?我需要改变什么?

2 个答案:

答案 0 :(得分:3)

您的SQL语法错误。它应该是

$STH = $DBH->prepare("DELETE FROM track_aktivnosti WHERE ID=:id AND ajdi=:ajdi");
$STH->bindParam(':id', $_POST['vrednostid']);
$STH->bindParam(':ajdi', $_POST['ajdi']);
$STH->execute();

答案 1 :(得分:1)

$stmt = $dbh->prepare("DELETE FROM track_aktivnosti WHERE (ID = ? and ajdi = ?)");
$stmt->execute(array($_POST['vrednostid'],$_POST['ajdi']));