[wp-trac] [WordPress Trac] #2722: long winded way to use two wpdb instances

WordPress Trac wp-trac at lists.automattic.com
Sat May 13 15:26:41 GMT 2006


#2722: long winded way to use two wpdb instances
-----------------------+----------------------------------------------------
       Id:  2722       |      Status:  new                     
Component:  General    |    Modified:  Sat May 13 15:26:41 2006
 Severity:  normal     |   Milestone:                          
 Priority:  normal     |     Version:  2.0.2                   
    Owner:  anonymous  |    Reporter:  Philnate                
-----------------------+----------------------------------------------------
 For my plugin I need to allow the user to use different databases, hosts,
 users and passwords therefor I created my own wpdb class instance:

 {{{
          $phpbbdb= new wpdb($pBBuser, $pBBpassword, $pBBdb, $pBBhost);
 }}}
 But if now something after this line access the database through the wpdb
 instance is using the phpbbdb resource id and therefor the Query isn't
 successful as the database don't hold these wordpress tables.
 To remove this problem I need to use this line at the end of my code:

 {{{
 $phpbbdb= new wpdb(DB_USER,DB_PASSWORD,DB_NAME,DB_HOST);
 }}}


 As I found out, this problem can easily be resolved by changing this line,
 within the wp-db.php file:

 {{{
                 $this->dbh = @mysql_connect($dbhost, $dbuser,
 $dbpassword);
 }}}

 into this one:

 {{{
                 $this->dbh = @mysql_pconnect($dbhost, $dbuser,
 $dbpassword);
 }}}
 I'm not sure if this change would create other problems as I'm not too
 deep into PHP+MySQL, but while working with the persistance connection, I
 didn't encounter some Problems.

 Thanks

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2722>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list