• Resolved alexandresena99

    (@alexandresena99)


    wpdb connection and WP Data Access connection

    I am developing plugins and for the word press database I use:
    global $wpdb;
    $c=$wpdb->get_results(“select * from table where id=1”);

    I installed WP Data Access, configured a remote database, tested it and it’s ok.

    How do I connect to remote database através do WP Data Access via the plugin page?
    global $wpda[0]; –> It does not work
    $c=$wpda[0]->get_results(“select * from table where id=1”); –> It does not work

Viewing 1 replies (of 1 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    HI @alexandresena99

    You can use class WPDADB to access a remote database like this:

    $wpdadb = WPDADB::get_db_connection( 'através );
    if ( null === $wpdadb ) {
    // Handle connection errors here
    }
    $c = $wpdadb->get_results('select * from table where id=1');

    WPDADB is a sub class of wpdb which means that you can use all wpdb methods and properties that you usually use with $wpdb.

    Hope this helps. Feel free to open a new thread if you have other questions.

    Best regards,
    Peter

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.