I want to be able to delete multiple users from the database, but the code below fails in some point. What happens is that only the last clicked user (i.e. the last element in the array $userIds) gets deleted.
What am I doing wrong?
from UserModel.php:
public function RemoveUser(Array $userIds) {
$query = 'DELETE FROM Users WHERE id IN (?)';
$stmt = $this->m_db->Prepare($query);
foreach ($userIds as $value) {
$stmt->bind_param('s', $value);
}
$ret = $this->m_db->DeleteUsers($stmt);
$stmt->Close();
return $ret;
}
from Database.php:
public function DeleteUsers(\mysqli_stmt $stmt) {
if ($stmt === FALSE) {
throw new \Exception($this->mysqli->error);
}
if ($stmt->execute() == FALSE) {
throw new \Exception($this->mysqli->error);
}
if ($stmt->fetch()) {
return true;
} else {
return false;
}
}