完全删除用户 [英] Delete user completely
问题描述
如果用户或管理员想要从站点中完全删除该用户。您将如何设置查询以从包含用户ID的每个表/子表中删除该用户。这是我的带有子表的表的列表,其中单个用户的可能ID可能是。
- user
- 相册-user_id
- block- user1_id
- blogdata_comments-comment_poster
- blogdata_feedback-feedback_userid
- 朋友-user1_id或user2_id
- 消息-消息创建者或message_target
- 通知-通知目标用户或notification_triggeredby
- 照片注释-photo_comment_poster
- streamdata-streamitem_creator或streamitem_target
- streamdata_comments-comment_poster
- streamdata_feedback-feedback_userid
- userphotos-photo_ownerid
@Dave我可能无法做到这一点,但我认为您可以做点什么
您显然需要在下面创建自己的非常基本的代码版本,但是它应该可以工作吗? / p>
编辑
只是认为ud已经需要其ip
$ db =新的mysqli(主机,用户名 ,密码,数据库);
$ removeUser =从(用户,专辑,块等)删除(用户ID在哪里)='$ user';
if(removeUser = $ db-> query($ removeUser)){
$ ipAddr = $ _SESSION ['REMOTE_ADDR'];
$ banList =插入禁止的(ipAddr)值('$ ipAddr')
die($ user。从所有表中删除);
if($ banList = $ db-> query($ banList)){
die($ user。添加到禁止列表);
} else {
die(向禁止列表添加。$ user。时出错);
}
}否则{
死亡(无法从所有表中删除用户);
}
If a user or an admin wanted to delete a user completely from the site. how would you go about setting a query to remove that user from every table/subtables where the users id is contained. Here is the list of my tables with the subtables where the possible id of an individual user could be.
- user
- albums - user_id
- block - user1_id
- blogdata_comments - comment_poster
- blogdata_feedback - feedback_userid
- friends - user1_id or user2_id
- messages - message_creator OR message_target
- notifications - notification_targetuser OR notification_triggeredby
- photo_comments - photo_comment_poster
- streamdata - streamitem_creator OR streamitem_target
- streamdata_comments - comment_poster
- streamdata_feedback - feedback_userid
- userphotos - photo_ownerid
@Dave i could be way off the mark with this but i think you could do something like this which would also stop the user from creating a new account.
You would obviously need to make your own version of the very basic code below but it should work?
EDIT just thought ud need their ip already
$db = new mysqli ('host', 'username', 'password', 'database');
$removeUser = "DELETE FROM (user, albums, block, and-so-on) WHERE `user-id`='$user'";
if(removeUser = $db->query($removeUser)){
$ipAddr = $_SESSION['REMOTE_ADDR'];
$banList = "INSERT INTO banned (ipAddr) VALUES ('$ipAddr')"
die($user . 'removed from all tables');
if($banList = $db->query($banList)){
die($user . 'Added to banned list');
}else{
die('Error adding ' . $user . ' to banned list');
}
}else{
die ('Unable to remove user from all tables');
}
这篇关于完全删除用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!