WordPress.org

Support

Support » Plugins and Hacks » Accessing non-wp database in plugin

Accessing non-wp database in plugin

  • For my plugin I need to pull some info from another local (non-wordpress) MySQL database. Is there a standard way to do this in wordpress (e.g. create a new wpdb object) or should I just use the normal mysql/mysqli/PDO code?

Viewing 1 replies (of 1 total)
  • You probably found the answer by now but for anyone else coming here from search engines (like me), I found the answer here:

    Stackexchange
    Stackoverflow

    It’s quite simple. Basically:
    $newdb = new wpdb( 'user', 'password', 'database', 'hostname' );

    Then use all the WordPress functions:
    $newdb->get_results("SELECT your query");

Viewing 1 replies (of 1 total)
  • The topic ‘Accessing non-wp database in plugin’ is closed to new replies.