Drupal共享表,但来自另一个数据库 [英] Drupal shared tables, but from another database

查看:65
本文介绍了Drupal共享表,但来自另一个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Drupal Multisite,其中包含数百个站点。我想共享一些表(例如横幅和角色),因此在更改横幅时(例如)我不必更新数百个站点。

I have a Drupal Multisite set up with hundreds of sites. I want to make some tables shared (like banners, and roles) so I don't have to update hundreds of sites when changing a banner (for example).

I知道可以使用settings.php中的这些字符串完成此操作:

I know this can be done using these strings in settings.php:

$db_url = 'mysql://user:pwd@localhost/example_db';

$db_prefix = array(
     'default'   => '',
     'users'     => 'subsite2_',
     'sessions'  => 'subsite2_',
     'authmap'   => 'subsite2_',
);

但是...如果我也有多个数据库设置怎​​么办?我有一个包含所有共享表的数据库..因此,在该数据库中,我有Banners表-我想让所有其他站点都可以使用。

But ... what if I have a multiple database setup as well? I have one database that holds all shared tables .. So in that database, I have the Banners table - that I want to have all the other sites to use.

设置多个数据库的原因是因为整个多站点设置包含数百个站点(到今年年底将有数千个站点)..因此每个数据库仅包含约20-40个站点​​。.我怀疑其中有很多表可以共享。

The reason for a multiple database setup is because the whole multisite setup consists of hundreds of sites (and will be thousands by the end of this year) .. so every database only holds about 20-40 sites.. I suspect a lot of these tables can be shared..

希望有人可以提供帮助。谢谢!

hope someone can help. thanks!

马可

推荐答案

设置类似内容的演练。它旨在仅共享用户数据,但原理可以扩展到几乎所有表。请注意,它不仅在表名前缀(或根本不在表名前缀之前)而且//仅在数据库选择器前加点号(例如,),在表前缀逻辑上使用技巧。 someDatabase.someTable 。因此,我不确定这将如何转换为PostgreSQL后端。而且,这意味着您仍然受限于单个数据库服务器,因为(AFAIK)没有任何机制可以在单个Drupal实例中使用两个不同的数据库连接。

There is a walkthrough to setup something like this. It aims at sharing only the user data, but the principle can be extended to more or less all tables. Note that it uses a 'trick' on the table prefixing logic by prepending not only (or not at all) a table name prefix, but also/only a database selector using the dot notation, e.g. someDatabase.someTable. So I'm not sure how this would translate to a PostgreSQL backend. Also, it means that you're still restricted to a single database server, as there is (AFAIK) no mechanism to use two different database connections in a single Drupal instance.

或者,您可以尝试通过某种复制/镜像功能将共享表映射到不同的数据库实例中,从而从数据库引擎的角度寻找解决方案。这样,您可以使用标准的Drupal多站点设置,在 Drupal背后进行表格共享。不过,不确定这将如何/是否起作用以及这将对锁定和其他并发问题产生什么后果。

As an alternative, you might try to find a solution from the database engine side of things by 'mapping' your shared tables into the different database instances via some kind of replication/mirroring feature. That way you could use the standard Drupal multisite setup, doing the sharing of tables 'behind the back' of Drupal. Not sure how/if this would work and what consequences this would have on locking and other concurrency issues, though.

这篇关于Drupal共享表,但来自另一个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆