WordPress.org

Ready to get started?Download WordPress

Forums

Creating new wpdb Object (2 posts)

  1. Philnate
    Member
    Posted 7 years ago #

    Hello,
    For my Plugins and Widget I want to allow(as already some requests hit my mailbox) that you're able to connect to other databases, which are maybe not accessable with the wp user and or on another host.
    Therefor I'm creating my own wpdb instance.
    With this line:
    $phpbbdb= new wpdb($pBBuser, $pBBpassword, $pBBdb, $pBBhost);

    Within my Plugin it's all working fine. But if after my Plugin are some plugins,widgets or something else which uses tables i get errors like this(if my wpdb instance uses another db than the wordpress one):
    TABLE xyz doesn't exist in this database

    So as it seems the $wpdb holds then the same connection as $phpbbdb does, but that shouldn't be as they're different instances of the wpdb-class?

    So I need to place at the end of my plugin this line:
    $phpbbdb= new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);

    Can someone tell me what causes this problem, which in my opinion shouldn't be?

    Thank you for your help!

  2. Philnate
    Member
    Posted 7 years ago #

    I found the solution for it. It can be solved by changing the mysql_connect to mysql_pconnect within the wp-db.php file.

Topic Closed

This topic has been closed to new replies.

About this Topic