smc
smc

Reputation: 205

PDO- Delete entire row

I'm trying to delete an entire row in a database table. Here I want to delete the row if $token and $user_id is matched.But my code is not working.

<?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();
?>

If I use this the code below it works perfectly.

<?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();
?>

I don't know why AND condition is not working.Or am I miss something?

Upvotes: 0

Views: 150

Answers (1)

Suresh Vaishnav
Suresh Vaishnav

Reputation: 101

Try using alone user_id = :user_id condition and check if its working, If not then there must be some problem in the user_id value.

Upvotes: 1

Related Questions