WordPress.org

Ready to get started?Download WordPress

Forums

Outside DB Connection (6 posts)

  1. Knight Vash
    Member
    Posted 5 years ago #

    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]

  2. whooami
    Member
    Posted 5 years ago #

    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?

  3. MichaelH
    Member
    Posted 5 years ago #

    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.

  4. Knight Vash
    Member
    Posted 5 years ago #

    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.

  5. MichaelH
    Member
    Posted 5 years ago #

    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

  6. Knight Vash
    Member
    Posted 5 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Topic