PDO-删除整行


PDO- Delete entire row

我正试图删除数据库表中的整行。在这里,如果$token$user_id匹配,我想删除该行。但我的代码不起作用。

<?php
 $delete_rt_string = $this->db_connection->prepare("DELETE FROM rt_strings WHERE rt_string = :rt_string AND user_id = :user_id ");
 $delete_rt_string->bindValue(':rt_string', $token, PDO::PARAM_STR);
 $delete_rt_string->bindValue(':user_id', $user_id, PDO::PARAM_INT);
 $delete_rt_string->execute();
?>

如果我使用下面的代码,它可以完美地工作。

<?php
 $delete_rt_string = $this->db_connection->prepare("DELETE FROM rt_strings WHERE rt_string = :rt_string ");
 $delete_rt_string->bindValue(':rt_string', $token, PDO::PARAM_STR);
 $delete_rt_string->execute();
?>

我不知道为什么AND条件不起作用。还是我错过了什么?

尝试单独使用user_id = :user_id条件并检查其是否工作,如果不工作,则user_id值一定有问题。