[wp-hackers] WP and Plugins DB connection conflicts
peter.westwood at ftwr.co.uk
Tue Jun 26 21:37:01 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Peter Adams wrote:
> sorry, let me be more clear.
> There are cases when plugins need to create/manage/teardown their own
> link to the same database that WP uses using the exact same user
> credentials. This is very handy when you need a dedicated or persistent
> db link or need to produce and ignore errors on that link. PHP's
> mysql_connect will attempt to reuse an existing connection with the same
> credentials unless you set the new_link bool.
If you want to produce and ignore errors then call $wpdb->hide_errors
and $wpdb->show_errors around your queries.
> What I was suggesting was to force php to create a new link to the DB
> when $wpdb is _first_ created - not every time it's accessed. The
> benefit here is that Wordpress is then guaranteed to have it's own db
> connection instead of potentially piggy-backing on one that is already
> created by a plugin that is using the same db credentials.
wp-db.php is included way before plugins and so it would be the other
way round -> the plugin would be piggybacking on the normal wpdb link.
I don't see how making this change to $wpdb to mean that it always
creates a new connection is benificial to most users of WordPress.
If you have a specific situation where you need this functionality then
override wpdb with your own db class using the functionality provided.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the wp-hackers