PDA

View Full Version : multiple databases question


c4smok
07-30-2008, 12:59 AM
I currently run vbulletin forums with other services linked in to the same database. But it has started to become really hard to manage.. around over 200+ tables..

I was wondering if there was a way I could put my services into another database and still use the plug-in system to have them linked into the forums for all the connections and vars. My current system I have one database with my services in tables of one database..

Thanks for reading, looking for a clean way to do this like a plugin on start or something.

Thank you for your time,
c4smok

Dismounted
07-30-2008, 06:50 AM
As long as the MySQL user for vBulletin has access to the other database, you can use the standard MySQL "database.table" syntax.
SELECT *
FROM database1.tableA

c4smok
07-30-2008, 10:19 PM
I seem to be getting a database error for the forum system when I try to use that.


This is the current code I use to bring over vars from other tables in the same database.

$uservar = $vbulletin->db->query_first("
SELECT *
FROM `table_servusers`
WHERE `username` = '" . $vbulletin->userinfo['username'] . "'
LIMIT 1
");


This is the changes I made based on your advice which I may not be doing correctly. The user for both databases have the same access also.


$uservar = $vbulletin->db->query_first("
SELECT *
FROM `mysite_database2.table_servusers`
WHERE `username` = '" . $vbulletin->userinfo['username'] . "'
LIMIT 1
");


The Error msg

Invalid SQL:

SELECT *
FROM `mysite_database2.table_servusers`
WHERE `username` = 'c4smok'
LIMIT 1;

MySQL Error : Incorrect table name 'mysite_database2.table_servusers
Error Number : 1103

Thanks for your time again,
c4smok

MoT3rror
07-31-2008, 03:11 AM
Try mysite_database2.table_servusers with the `.

c4smok
07-31-2008, 03:41 AM
its working =)

your great

thanks,
c4