variorum
Latest Blog Entries:
More at PSB-Blog
powered_by.png, 1 kB

More than one wpdb Class PDF Print E-mail
Written by Administrator   
Sunday, 14 May 2006

You're using components which create their own wpdb-class instance and after them no component which access a database is working right. And just return this kind of Error: Table XYZ doesn't exist.
Or you create your own widgets and/or components and you don't want to put at the of your code this kind of line:

$mywpdb=new wpdb(DB_USER,DB_PASSWORD,DB_NAME,DB_HOST);
Then read on.

To remove this bug it's needed to do just one change within a wordpress core file. In my opinion this change needs also to enter an offical wordpress release as this problem is against the definition of an object-instance.
Normally an instance doesn't affect another one of the same object...but in this case they do. So now we're going to change it: open the file wp-db.php which is within the folder wp-includes. Search for this line:

$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
And simply add a p into it:
$this->dbh = @mysql_pconnect($dbhost, $dbuser, $dbpassword);
So the problem is that the connection which is used is been not persistance so the next connection which is created takes the resource id of the last one...and so it screws up. By using mysql_pconnect you're using persistant connections so each new connection get it's own connection.(The explaination can be not totally wrong, but should give you the hint)

This fix also affects ezSQL as the wpdb class is based on it.

 
Next >
Polls
Should I add a Wiki as an online Manual for the Products?
 
Who's Online
We have 12 guests online
PhSoftware hosted sites:
Praxis Heinze

Website of my mothers surgery
© 2003-2010 PhSoftware.de
Joomla! is Free Software released under the GNU/GPL License.