Customizing SMF > SMF Coding Discussion

Question about sharing tables

<< < (2/4) > >>

MrCue:
Wouldnt it be a good idea if all the table names were defined in settings.php. That way we can easily change which tables are shared.

Oldiesmann:
That would either create a huge server load (having it look at Settings.php everytime it wanted to run a query) or add a ton of global variables (one for each table name), which would in turn increase the size of Settings.php and just about every other file. The way it's done now is much easier.

DLD:
what I was looking for is something like yabb gold was where you could change the folder of members that way several installs could share the same folder.

The problem I am going to run into is I have 3 seperate mysql servers (we have sites on different hosts) so therefore the mysql database and the tables are different. I don't mind converting everything to one database but we have over 900 members total and over 20000 posts and I relly want to keep them instead of starting all over again just to get what I want out of it.

Jack.R.Abbit™:

--- Quote from: Oldiesmann on April 20, 2004, 05:58:26 PM ---That would either create a huge server load (having it look at Settings.php everytime it wanted to run a query) or add a ton of global variables (one for each table name), which would in turn increase the size of Settings.php and just about every other file. The way it's done now is much easier.

--- End quote ---
I had considered this for a mod to do some time in the idle future (which could be never).  I planned it like so...

rather than using things like this:
{$db_prefix}members and {$db_prefix}attachments

$db_prefix could be an array and you would use things like this:
{$db_prefix['members']}members and {$db_prefix['attachments']}attachments

$db_prefix is already a made global for the functions that need it so you are not really adding a bunch of globals... just making one a bit larger.  And you wouldn't have to look in Setting.php everytime.  It would really work exactly as it does now, except that the $db_prefix array in Settings.php would need to have an entry for each tablename.  And of course the admin page might need to be adjusted to make it so you can change each one.

Converting to something like this is not easy though because many (most? all?) the queries would need to be rewitten slightly because I think the $db_prefix array can't be put into the query string the same way.  It would take more than just a bunch (33) of search and replaces.

MrCue:
i think you can do {$db_prefix[tbl_name]} without escaping from the string.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version