Calling wp_set_wpdb_vars()
after replacing $wpdb
will probably do the trick.
$wpdb = new My_DB();
wp_set_wpdb_vars();
However, the only officially supported way to replace wpdb
is to place a db.php
in wp-content folder. If you can, I would suggest to do that.