Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: rebuilding topics DB


_ck_
Participant

@_ck_

tested working – at least for my setup:

function rebuild_topics() {
global $bbdb;
// currently only rebuilds last post pointers, last poster name, last poster id, last topic post date
// todo: rebuild entire topics table
// warnings: hard coded for WP user table - backup your DB before using
// run the built-in post/topic recount first

echo "t<br>n";
if ( $topics = (array) $bbdb->get_results("SELECT topic_id,post_id,poster_id,post_time FROM <code>bb_posts</code> a WHERE post_position=(SELECT MAX(post_position) FROM <code>bb_posts</code> WHERE topic_id=a.topic_id) AND post_status = '0' GROUP BY topic_id ") ) :
echo "tt" . __('Calculating last posters for each topic...') . "n";
foreach ($topics as $t) {
echo $t->topic_id."... ";
$user_login=$bbdb->get_var("SELECT user_login FROM wp_users WHERE ID='$t->poster_id'");
$bbdb->query("UPDATE $bbdb->topics SET topic_time='$t->post_time',topic_last_poster= '$t->poster_id', topic_last_poster_name='$user_login', topic_last_post_id='$t->post_id' WHERE topic_id = '$t->topic_id'");
}
endif;
echo "<br> tt" . __('Done calculating last posters.');
}

Skip to toolbar