MyBB Community Forums

Full Version: More than 1 forum sharing database?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering if anyone has a modification or knows how to use 1 database and use the same users, post counts, etc. with two forums?
Hmm, if you're going to use the same users, posts etc, why make two forums in the first place?
post counts, I don't think he has any intention of using the same posts. He wants to, basically integrate one with another.
If he wants to merge two forums into one, the MyBB Merge System will do it Toungue
He wants to keep them separate, but have all the same details as they did before. Like two different forums, on different topics (ie Golf and Football per say). So the Golf forum the same users will be registered and have the same post count, avatar, signature, etc as the Football forum.
I suppose that it may be possible to modify MyBB to do this.

For instance, take this code in user.php:

/**
 * Checks if a user with uid $uid exists in the database.
 *
 * @param int The uid to check for.
 * @return boolean True when exists, false when not.
 */
function user_exists($uid)
{
	global $db;
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='".intval($uid)."' LIMIT 1");
	if($db->fetch_array($query))
	{
		return true;
	}
	else
	{
		return false;
	}
}

If you change:

$query = $db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid='".intval($uid)."' LIMIT 1");

to

$query = $db->query("SELECT * FROM global_users WHERE uid='".intval($uid)."' LIMIT 1");

You could pull all user information from one master table among many forums. You could also combine this with something like my MyBB Multiforum Script to make unlimited forums that share a user base.

Just replace everything that looks to the variable TABLE_PREFIX that relates to MyBB user functions with a static table containing all user data and you should be good to go. The only trouble I see is setting an admin as admin of one forum but not all.

BMR777
^ It's probably much easier to modify the db_mysql*.php files' query() function to automatically replace such table names. The main issues with sharing user tables is the cache, however (you'll have to update the cache for each forum).


ahero4heor Wrote:He wants to keep them separate, but have all the same details as they did before. Like two different forums, on different topics (ie Golf and Football per say). So the Golf forum the same users will be registered and have the same post count, avatar, signature, etc as the Football forum.
I still don't see how that should be on two completely separate bulletin boards. Just make ONE bulletin board with two forums, and then subforums within - simple.