Open main menu

手册:$wgDBprefix

This page is a translated version of the page Manual:$wgDBprefix and the translation is 100% complete.
Other languages:
English • ‎español • ‎français • ‎magyar • ‎polski • ‎português do Brasil • ‎中文 • ‎日本語
数据库设置: $wgDBprefix
数据表名称的前缀。
引进版本:1.4.0
移除版本:仍在使用
允许的值:(字符串)
默认值:''

详情

数据表名称的前缀。 若您仅能够访问单独一个数据库且想安装多于一个版本的MediaWiki,或另有其他应用也使用该数据库。您可以给数据表给予唯一的前缀,来避免命名冲突或混淆。

例如,若您使用前缀 'wiki_' ,那么数据表 'page' 将以 'wiki_page' 的名称替代。

您需要在初始配置时设置此项,或者在以后手动更改表名称。 更改此设置不会自动更新数据库中表的名称。

如果您的数据库是Postgres,那么请使用schemas替代(参阅$wgDBmwschema )。

常用值

默认情况下,许多安装程序将表前缀“$wgDBprefix”设定为“mw_”。 [1][2][3]

  小心:
  • Do not change $wgDBmwschema after Setup.php has been included. Note: Setup.php initializes various paths, includes some common files, starts sessions, and performs various other setup tasks for a request. It is not related to the installation or setup of MediaWiki.
  • Only files in includes/db/ should use $wgDBmwschema, while everything else should use the dbSchema() method provided by the Wikimedia\Rdbms\IDatabase interface or extract it from the getDomainId() method in either the Wikimedia\Rdbms\ILoadBalancer or the Wikimedia\Rdbms\ILBFactory interface. The DatabaseDomain class can extract such components from a database domain ID.
  • If you configure $wgDBservers or $wgLBFactoryConf, you still need to define $wgDBname, $wgDBmwschema (if applicable for the DB type), and $wgDBprefix (if applicable for the DB type). The combination of $wgDBname, $wgDBmwschema, and $wgDBprefix define the current wiki's database domain. This is also called the local database domain. The 'dbname' and 'tablePrefix' settings in $wgDBservers and $wgLBFactoryConf only define the default DB/prefix when a connection is requested with DatabaseDomain::newUnspecified()->getId() (the empty string) as the database domain, e.g. wfGetDB( DB_REPLICA, [], '' ). Note that functions calls like wfGetDB( DB_REPLICA ), which simply omit the database domain, are assumed to refer to the local database domain.

参考资料

另请参阅