MyBB Community Forums

Full Version: Global table names
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

Could you, in your next release, replace table names and prefixes in different files by global variables in one file ?

For exemple :

$query = $db->query("
			SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
			FROM ".TABLE_PREFIX."posts p
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
			WHERE p.tid='$tid'
			ORDER BY p.dateline ASC
			LIMIT 1
");

By

$query = $db->query("
			SELECT u.uid, u.username, p.pid, p.username AS postusername, p.dateline
			FROM ".GLOBAL_POSTS."
			LEFT JOIN ".GLOBAL_USERS." u ON (u.uid=p.uid)
			WHERE p.tid='$tid'
			ORDER BY p.dateline ASC
			LIMIT 1
");

And in a new file for exemple : table.php

define('GLOBAL_USERS',            $table_prefix . 'users');
define('GLOBAL_POSTS',            $table_prefix . 'posts');

Thanks a lot !
I don't see any advantage in your suggestion... so why should this be done?
If someone would like to change a table name he will can, and the biggest advantage will be when you want to have multiple mybb boards with same users table, you will have to change only the table name in the table.php.

Do you see what i mean ?
That's a big change (remember we have a lot of queries in nearly every file) which has an advantage to nearly 0% of our users so I doubt this will ever introduced. Also I doubt that changing all queries to use the same users table on two boards will work. But if you need this you can simply add a small if to the query method in the db class.
Also, this wouldn't even work with our db functions such as simple_select() or delete_query() which are used all over the script. Unless we modify them too, which would break all plugins.. So I'm sure this won't get in 1.8.
Hum i understand.. But it's done like that on phpbb and it works fine .. However I think that's the only advantage they have over mybb ^^

Quote:But if you need this you can simply add a small if to the query method in the db class.

Could you clarify this solution? Because i don't like this method : http://community.mybb.com/thread-80412.html