1

我正在构建一个drupal 多站点,比如childone 和childtwo。两者都有各自的数据库。现在的要求是共享一些表,例如。在站点 childone 中创建的用户也必须在站点 childtwo 中具有相同的访问权限。任何人都可以向我推荐正确的逐步解决方案吗?

问候

4

1 回答 1

3

您需要使用表前缀,settings.php 解释了如何做到这一点:

 * You can optionally set prefixes for some or all database table names
 * by using the 'prefix' setting. If a prefix is specified, the table
 * name will be prepended with its value. Be sure to use valid database
 * characters only, usually alphanumeric and underscore. If no prefixes
 * are desired, leave it as an empty string ''.
 *
 * To have all database names prefixed, set 'prefix' as a string:
 * @code
 *   'prefix' => 'main_',
 * @endcode
 * To provide prefixes for specific tables, set 'prefix' as an array.
 * The array's keys are the table names and the values are the prefixes.
 * The 'default' element is mandatory and holds the prefix for any tables
 * not specified elsewhere in the array. Example:
 * @code
 *   'prefix' => array(
 *     'default'   => 'main_',
 *     'users'     => 'shared_',
 *     'sessions'  => 'shared_',
 *     'role'      => 'shared_',
 *     'authmap'   => 'shared_',
 *   ),
 * @endcode

因此,对于您的示例,对于您的 childone 站点的 settings.php,您将具有以下内容:

'prefix' => array(
  'default'    => 'childone_',
  'user'       => 'shared_',
  'sessions'   => 'shared_',
  'role'       => 'shared_',
  'permission' => 'shared_',
);

而对于childtwo的settings.php,也很相似:

'prefix' => array(
  'default'    => 'childtwo_',
  'user'       => 'shared_',
  'sessions'   => 'shared_',
  'role'       => 'shared_',
  'permission' => 'shared_',
);

除了共享表之外,所有表都将以 childone_ 或 childtwo_ 为前缀,在运行安装后,它们将以 shared_ (或任何您想要的)为前缀。

于 2012-10-19T07:41:04.593 回答