• Okay… I have a very unique situation… For security, and design constraints I want to use a seperate file to handle incomming data, and have it process it, then add it to the DB, for another file, that is built into the main portion of my planned plugin to read from the DB and handle the display creation, etc… But there in lies my problem… Since this file is called by itself, there is no DB connection for it, as there is for anything called via WP’s addon system… What would be the easiest way to get a DB connection for it, preferably from WP itself, since I would like to keep the DB calls consistent, and just use the features from WP’s DB class to handle them?

    [moderated–bump removed. Please refrain from bumping as per Forum Rules]

Viewing 5 replies - 1 through 5 (of 5 total)
  • What would be the easiest way to get a DB connection for it, preferably from WP itself, since I would like to keep the DB calls consistent, and just use the features from WP’s DB class to handle them?

    if i understand your question, you want to use wordpress functions to make your database connections. if thats the case, than you need to include wp-blog-header.php.

    you also want to have this in that file,

    define('WP_USE_THEMES', false);

    oh damn Im “blocked” – yah right, sure… and you couldnt figure this out?

    If a table is kept in the same database as the rest of the WordPress tables then you can use the wpdb Class to access data in that table.

    Thread Starter Knight Vash

    (@infiniteknight)

    MichaelH, the data will be kept in the same DB, but the file containing the code to process and insert the data initially, will be called from OUTSIDE of WP, not inside of it… Hence the need for it to have it’s own DB connect created when it is called… The actual full use of the data will be handled inside WP, but due to my way of designing, and the need for special security routines and such, the file that handles the incomming processing is kept seperate from the plugin itself, and WP… It is much easier to secure that way.

    whooami has pointed you in the right direction…I was just highlighting the info about wpdb if you decide to use it.

    Review Integrating_WordPress_with_Your_Website

    Thread Starter Knight Vash

    (@infiniteknight)

    Bringing in the full header file, along with it’s theme code, and such would be over kill though… I will experiment with including only wp-load.php itself, since there are only two forms of data that come out of the script I am working on… Going back to the sender, is a compressed string, that basically is an acknowledgement that the data it sent was recieved and processed, and the data that gets added to the DB. Beyond that, the script doesn’t interact at all with any user or other display code… It is a purely back end interface for an external data source. That’s why all I need is a DB connect, and for the sake of keeping everything nice, neat, and compact, I want to use the $wpdb class structure for it… Will let others know what I come up with…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Outside DB Connection’ is closed to new replies.