PDA

View Full Version : Multiple instances of vB's DBwrapper...


Nebula
04-06-2002, 11:22 PM
Hey all. I'm making something, and I'm trying to use multiple instances of vBulletin's DBwrapper. But when I do, it starts freaking out.

I'm trying to connect to two databases at once. But I find that when I create a new instance, all instances of the DBwrapper use the most recently created instance in the script.

If you didn't understand that, it's my fault :mad:

I'm trying to have two DBwrappers open. It doesn't work. I configure each for the right DB, but each instance ($DB_site and $mySQL) are the same.

Any of PHP whizes know why this is? I know a lot of PHP, but I can't figure out why this is...

BTW...If you're wondering why I want to connect to multiple DBs, one DB = vBulletin, the other DB = my Website.

Admin
04-07-2002, 10:57 AM
It's because mysql_query() queries the last used database, so whenever you create $mySQL the selected database changes in $DB_site as well. I think...

Try redefining the DB_Sql_vb class to use mysql_db_query() (http://php.fastmirror.com/manual/en/function.mysql-db-query.php) in the query() method instead of just mysql_query(). As the first parameter for mysql_db_query() use $this->dbname (or whatever the variable is).

Good luck. :)