You're right, I didn't even think of that.
This should help with cleaning up the orphans, but I don't know if I missed any tables. But at least you can see how to easily add a table and column that needs to be updated. This is assuming of course he hadn't gotten around to running the code yet, 'cause if he did the links are well and truly gone and he will have to do it manually =(
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
$users = dbquery("SELECT user_name,user_id FROM " . DB_USERS . " ORDER BY user_id"
;
$count = 1;
$tables = array(
array("table" => DB_DOWNLOADS, "column" => "download_user"
,
array("table" => DB_FORUM_POLL_VOTERS, "column" => "forum_vote_user_id"
,
array("table" => DB_MESSAGES, "column" => "message_to"
,
array("table" => DB_MESSAGES, "column" => "message_from"
,
array("table" => DB_PHOTOS, "column" => "photo_user"
,
array("table" => DB_PHOTO_ALBUMS, "column" => "album_user"
,
array("table" => DB_POLL_VOTES, "column" => "vote_user"
,
array("table" => DB_POSTS, "column" => "post_author"
,
array("table" => DB_RATINGS, "column" => "rating_user"
,
array("table" => DB_SUBMISSIONS, "column" => "submit_user"
,
array("table" => DB_SUSPENDS, "column" => "suspended_user"
,
array("table" => DB_THREADS, "column" => "thread_author"
,
array("table" => DB_THREAD_NOTIFY, "column" => "notify_user"
);
while ($user = dbarray($users)) {
dbquery("UPDATE " . DB_USERS . " SET user_id = " . $count . " WHERE user_name = '" . $user['user_name'] . "'"
;
foreach ($tables as $table) {
dbquery("UPDATE " . $table['table'] . " SET " . $table['column'] . " = " . $count . " WHERE " . $table['column'] . " = " . $user['user_id']);
}
$count++;
}
dbquery("ALTER TABLE " . DB_USERS . " AUTO_INCREMENT = " . $count);
$users = dbquery('SELECT user_id,user_name FROM ' . DB_USERS . ' ORDER BY user_id'
;
print "<table>";
while ($user = dbarray($users)) {
print "<tr><td>" . $user['user_name'] . "</td><td>" . $user['user_id'] . "</td></tr>";
}
print "</table>";
?>[/syntaxhighlighter]