• I have website – wordpress multisite and I’d like to partition blogs between 16 or more DB.
    All DB’s have the same username DB and password DB and the same prefix DB.

    How I must set it in db-config.php ?
    New blogs will be automatic migrated to differents DB?

    $wpdb->add_database(array(
    	'host'     => 'localhost',
    	'user'     => 'xxx',
    	'password' => 'xxx',
    	'name'     => 'xxx',
    	'write'    => 1,
    ));
    
    $wpdb->add_database(array(
    	'host'     => 'localhost',
    	'user'     => 'xxx',
    	'password' => 'xxx',
    	'name'     => 'xxx',
    	'write'    => 0,
    	'read'     => 3,
    	'dataset'  => 'global',
    	'timeout'  => 0.2,
    ));
    
    $wpdb->add_database(array(
    	'host'     => 'localhost',
    	'user'     => 'xxx',
    	'password' => 'xxx',
    	'name'     => 'xxx',
    	'write'    => 0,
    	'read'     => 3,
    	'dataset'  => 'global',
    	'timeout'  => 0.2,
    ));

    Do I have to this code with prefix DB? If YES: myprefix or myprefix_
    When I add this code, my website is not working.

    $wpdb->add_callback('my_db_callback');
    function my_db_callback($query, $wpdb) {
    	// Multisite blog tables are "{$base_prefix}{$blog_id}_*"
    	if ( preg_match("/^{$wpdb->base_prefix}\d+_/i", $wpdb->table) )
    		return 'myprefix';
    }

    https://www.ads-software.com/plugins/hyperdb/

  • The topic ‘Partitioning DB’ is closed to new replies.