Thursday, April 21, 2011

WP Function to retrieve database connection

Is there a function or command that pulls the db connection info from the WP blog? I am writing a Plugin which would have to connect to the db to retrieve the info, wondering if there was one single command/function i could call which could connect. this would make the plugin portable and would work on any WP blog. is this possible?

From stackoverflow
  • See the Interfacing with the Database docs.

    You should just be able to use the global (curse you, Wordpress) variable $wpdb in your plugin functions, ie:

    global $wpdb;
    //do stuff
    

    Plugins also have a few methods for storing "options" in the database. I just found this article, it details things fairly well.

    HollerTrain : lol one time a global var is awesome
    zombat : Wordpress is all global variables unfortunately. It causes a lot of problems if you get into anything more than the simplest custom development :(

0 comments:

Post a Comment