Using two different DB users on one WP install

I have setup WP instance with 2 different database, one for read only and other for admin purpose.

But once the admin make the changes, then the ADMIN-DB should be copied and added to SLAVE-DB server.

// check if url contains wp-login or wp-admin and then create DB configuration for Master DB else Slave DB.
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if ( false !== strpos( $url, 'wp-admin' ) || false !== strpos( $url, 'wp-login' ) ) {
    define( 'DB_NAME', 'SLAVE_DB_NAME' );
    define( 'DB_USER', 'SLAVE_DB_USER' );
    define( 'DB_PASSWORD', 'SLAVE_DB_PASSWORD' );
    define( 'DB_HOST', 'SLAVE_DB_HOST' );
} else {
    define( 'DB_NAME', 'MASTER_DB_NAME' );
    define( 'DB_USER', 'MASTER_DB_USER' );
    define( 'DB_PASSWORD', 'MASTER_DB_PASSWORD' );
    define( 'DB_HOST', 'MASTER_DB_HOST' );

}