splitting datas in 101 databases #131
Unanswered
deepakchandarr
asked this question in
Q&A
Replies: 2 comments 6 replies
-
Please explain the errors that you got. |
Beta Was this translation helpful? Give feedback.
6 replies
-
it works now , |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I would like to shard data in between 101 databases, one global db, and 100 blog DB for WordPress multisite . its like the last 2 digits of the blog id should decide which database it needs to be settled,
for example,
We can predict what database a blog is in by looking
and i used this call back ,
function pb_db_callback( $query, $wpdb ) {
if ( preg_match( "/^{$wpdb->base_prefix}\d+_/i", $wpdb->table ) ) {
$last_two_digits = (int) substr( $wpdb->blogid, -2 );
$db = sprintf( 'db%02d', $last_two_digits ); // db00, db01, db02, ..., db99
return $db;
} else {
return 'global';
}
}
$wpdb->add_callback( 'pb_db_callback' );
but im getting error , can anyone help me out in setting this up.
i took reference from a blog whcih use ludicrous db " here "
Beta Was this translation helpful? Give feedback.
All reactions