The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
working with 2 database help please
ok i have 2 dbs on same host
1 is vbulletin and the 2nd is just some info i need about things now mysql user have axx to both databases so i thought ok vbulletin will use $DB_site and for the other info ill user $predb so when im doing $Db_site->query($query) its will run on vbulletin db and when im doing $predb->query($query) its will run on the other database sounds simple right ? so i edited config.php and added $predbname = ''; so i can use it for $predb also i open init.php to add new db_class and added this code : PHP Code:
every time server tries to connect to host he connect to db in $predb so he wont find vbulletin info now my qustion is if there any way that i can use this method with out doing mysql_select_db every time i want to use $predb instead of $DB_site ??? help appricated. thanx MiZ |
#2
|
||||
|
||||
To work with a seperate DB all you need to do is prefix the tablename in your queries with the database name.
e.g. [sql] SELECT field FROM dbname." . TABLE_PREFIX . "table as table [/sql] |
#3
|
|||
|
|||
nahh i sloved it with better idea
PHP Code:
all i do is switchdb(); on start and end of function... Quote:
i can add new define like PHP Code:
[sql] SELECT field FROM " . MIZDB. "table as table [/sql] as my other table dosent user prefix btw is my first way takes more qureys ? |
#4
|
||||
|
||||
Why make a function when you can just put $DB_site->select_db('dbname'); in your code before you run the query, and then switch it back afterwards, seems kinda redundant
|
#5
|
|||
|
|||
Quote:
but i made it on the easyest way that can be in init.php i added : PHP Code:
PHP Code:
PHP Code:
so when i want to use my other db i use PRED in query |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|