• Hi everyone.
    I am projecting to use WordPress for developing an interface to the database of my organization, let’s call it “myorg” database.
    I am not a great expert of WP and I need to understand a base thing.
    Can WP manage a database different from its own database “wordpress” or I must import all my own “myorg” database tables in the “wordpress” db ?

Viewing 5 replies - 1 through 5 (of 5 total)
  • There is a database object that is a global variable $wpdb that a lot of the functions use. But you could define another variable for another database object, I think. I haven’t tried it. It is only for connecting, reading, writing. So all the data manipulation after the query would be new functions for your data, so it might work.

    https://developer.wordpress.org/reference/classes/wpdb/

    Thread Starter onomastico

    (@onomastico)

    Thank you Joy for your answer.
    I would like to use WP to speed up the job, so please, let me understand : how do usually people move in this situation ? I mean, if I have a starting database I need to work with, is the normal behaviour to import that database in “wordpress” database or not ? If I would like to use some plugin to build my interface , what is better to do with my external database ?

    I don’t think there is anything “normal”. You just need to decide how you want to proceed. What are the benefits and detriments to keeping two databases, and same for merging. Think about data entry, user access (permissions and interface), data presentation, mixture of data on pages, reports, security, coding impact.
    There is no normal, and no one can judge your situation but you.

    Dion

    (@diondesigns)

    You can use different databases as long as the WordPress DB user can access both databases. I suggest creating a special DB user that has appropriate access to only the two databases.

    You also don’t need to use the WordPress DBAL in your code; in fact, for this purpose you probably should not. As long as you add the following lines in your WordPress code:

    global $wpdb;
    $dbh = $wpdb->__get('dbh');

    you can use standard mysqli procedural functions to simultaneously access the two databases, using $dbh for the database handle. Just remember to never call the mysqli_close() function in your code…bad things will happen if you do 🙂

    Thread Starter onomastico

    (@onomastico)

    Uhmm…Thanks to Joy and DD for your answers.
    Reading your answers and googleing I’ve matured a different question changing my starting point.
    If already exist some plugin I can use to realize stuff like data entry, data presentation interfaces I prefer to use them, but it’s not easy for my level of wordpress universe knowledge to understand what to choose and even how to choose.
    Yes even “how” becaouse, for example, pheraps there is out there a fantastic plugin for csv data presentation and I just need to code query and passing data in the right format to the plugin…

    Can somebody give me some points to refer to, articles or plugin names, something different from the wordpress plugin directory.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘database other than “wordpress” database’ is closed to new replies.