简体   繁体   中英

Simple DELETE php pdo query

I want to delete data but with multiple condition so I write this:

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

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

but I have error is statement? What do I need to change?

your SQL syntax is wrong. It should be

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM