I am trying to write mysql query with php prepared query.
First, the query
$query="delete from friends where UserA=?, UserB=?
or (UserB=?, UserA=?)";
I want to delete friends entry from database. The entry can be in any order. Like, a friends relation can be entered as UserA to be friend of UserB or UserB to be friend of UserA. But there is only one entry anyway. So to check make sure the entry is deleted I am trying to find and delete it in any of both possible cases.
Second,
I am confused with passing the parameters to the above sql query. The parameters in the above query are four. So I am guessing to pass four parameters. But I think if i do it $stmt->bind_param('ii',$userAid, $userBid) this should work???
$stmt=$mysqli->stmt_init();
$stmt->prepare($query);
$stmt->bind_param('iiii',$userAid, $userBid, $userAid, $userBid);
$stmt->execute();
$query="delete from friends where (UserA=? AND UserB=?) OR (UserB=? AND UserA=?)";. you should use "AND", not ",". the rest seems fine