PDA

View Full Version : change thread ownership


sabret00the
06-05-2004, 10:52 PM
basically i would like to select XX ammount of threads (randomly) in a forum (forumid=ZZ) posted by user AAA and change it so that user BBB appears as the poster.

Xenon
06-06-2004, 12:14 PM
well, you have to change the userid od the first post of those threads, and then run the update thread function

so like that:

$posts = $DB_site->query("
SELECT post.postid, thread.threadid
FROM thread
INNER JOIN post ON (post.postid = thread.firstpostid)
WHERE thread.forumid = ZZ
AND post.userid = AAA
ORDER BY RAND()
LIMIT XX
");
require_once('./includes/functions_databuild.php');

while ($post = $DB_site->fetch_array($posts))
{
$DB_site->query("UPDATE post SET userid = BBB WHERE postid = $post[postid]");
build_thread_counters($post['threadid']);
}


note, that it's not the optimal way to do it, as it produces x queries per post, but if your limit isn't too big, it should work :)

sabret00the
06-06-2004, 04:23 PM
thanks xenon, you're a diamond :D

Xenon
06-06-2004, 05:20 PM
you're welcome :)

*gg* but just a raw one ^^