你在这里

DRUPAL的伪读写分离

主标签

settings.php节选:

   
      $databases['default']['default'] = array(
            'driver' => 'mysql',
            'database' => 'databasename',
            'username' => 'username',
            'password' => 'password',
            'host' => '192.168.100.1',
            'port' => 3306,
            'prefix' => '',
            'collation' => 'utf8_general_ci',
          );   
      $databases['custom_db']['default'] = array(
            'driver' => 'mysql',
            'database' => 'databasename',
            'username' => 'username',
            'password' => 'password',
            'host' => '192.168.100.2',
            'port' => 3306,
            'prefix' => '',
            'collation' => 'utf8_general_ci',
          );                       

数据库切换代码:

        db_set_active('cutome_db');
Drupal 版本: 

猜你喜欢