Title: wpdb issue
Last modified: August 19, 2016

---

# wpdb issue

 *  [lerizzle](https://wordpress.org/support/users/lerizzle/)
 * (@lerizzle)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wpdb-issue/)
 * I created a plugin that uses a different database than the default wp database.
   So I say:
 * $newwpdb = new wpdb(connection settings here)
 * It all work fine but then I have plugins that call mysql_query() without a connection
   setting and this seams to use the $newwpdb I set above in a different plugin 
   rather than global $wpdb.
 * Is that as expected? Any suggestion as to how I can prevent that?
 * Thanks

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

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/wpdb-issue/#post-1328883)
 * I know you can save and restore $wp_query with:
 *     ```
       $tempquery = clone $wp_query;
       -- do stuff with my query --
       $wp_query = clone $tempquery;
       ```
   
 * It might be possible to do the same with $wpdb.
 *  [riyaz123](https://wordpress.org/support/users/riyaz123/)
 * (@riyaz123)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/wpdb-issue/#post-1329178)
 * Thanks vtxyzzy.
 * This precisely helped. Powerful tip 🙂

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

The topic ‘wpdb issue’ is closed to new replies.

## Tags

 * [wpdb](https://wordpress.org/support/topic-tag/wpdb/)

 * 2 replies
 * 3 participants
 * Last reply from: [riyaz123](https://wordpress.org/support/users/riyaz123/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/wpdb-issue/#post-1329178)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
