[wp-hackers] What is the correct way to open and close another database from a plugin?

Shelley Powers burningbird at gmail.com
Wed Jul 14 01:23:31 UTC 2004


I'd have to think though that there are a lot of PHP APIs that you can
use to interface with the database for non-blog related activit
--including several that handle comments and/or community posting.

The surest path to failure of a technology is to begin to see it as
the solution for all problem or needs. That's what's happened in the
syndication world.

I can imagine how complicated the functions would start to get if
their purpose starts going beyond the maintenance of Wordpress, the
weblog. And with more moving parts, more places to break.

So I guess this would be a request to the WP hackers to use caution
with something like this -- not to allow a natural 'tweaking' impulse
to lead to loss of focus.

Shelley


On Tue, 13 Jul 2004 21:13:59 -0400, Scott Merrill <skippy at skippy.net> wrote:
> David House wrote:
> > Quoting Ian Barton <lists at manor-farm.org>:
> >
> >>wp-db.php has a class to open and close a database, but this seems to be
> >>hard wired to the WordPress db.
> >
> >
> > Try this:
> >
> > $mynewdbconn = new wpdb($username, $password, $dbname, $host);
> >
> > wpdb is just a class: you can create as many instances of it as you want. The
> > variable $wpdb happens to be one created by default, and it is this variable,
> > not the class, that is 'hard-wired' into the WP database.
> 
> That works for wp-db functions, but unfortunately all the other WP
> functions are hard-wired into the global $wpdb object.
> 
> For example, I'd like comment-enable some non-blog data without
> re-inventing the commenting wheel.  I'd like to use the WP comment
> functions; but in order to do that, I need an alternate config file
> (say, my-config.php), which specifies my table prefix.  Unfortunately
> the config file calls wp-settings.php, which in turn calls vars.php,
> which requires the entirety of the WP database layout.  I don't want or
> need a completely duplicated WP database structure just to support
> comments on some non-blog data -- I just need the comment bits!
> 
> Consider this a feature request for more modular -- or override-able --
> core functions.
> 
> 
> 
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
>



More information about the hackers mailing list