简体   繁体   English

TYPO3扩展:在安装过程中创建数据库视图

[英]TYPO3 Extension: create database view during installation

In my TYPO3 extension I use a foreign table. 在我的TYPO3扩展名中,我使用了一个外部表。 I've created 2 views providing data of this table in the manner my extension needs. 我已经创建了2个视图,以我的扩展程序需要的方式提供此表的数据。

The question is - how can these views be created at installation time? 问题是-在安装时如何创建这些视图?

Views defined in " ext_tables.sql " are ingored by installation routine. 安装例程会迷惑“ ext_tables.sql ”中定义的视图。

I've tried to use file " ext_tables_static+adt.sql ". 我尝试使用文件“ ext_tables_static + adt.sql ”。 This variant works only for INSERT statements. 此变体仅适用于INSERT语句。

The only thing I've got to work is variant described here using signal slot dispatcher (sounds complicated but it is really not! Provided documentation is very good). 我唯一需要做的就是在这里使用信号槽分配器描述变体(听起来很复杂,但实际上并非如此!提供的文档非常好)。

But I can't believe it that there is no native way (like ext_tables.sql ) to solve such problems. 但是我不敢相信没有本地方法(例如ext_tables.sql )可以解决这些问题。

I did some research on this issue some time ago. 我前一段时间对此问题做了一些研究。 There was no other way to achive what you want at that time and I doubt there's evolved a new one in the meantime. 当时没有其他方法可以满足您的需求,我怀疑与此同时已经开发了一种新方法。

  • I ended up using the hook you mentioned and made it read and execute all Configuration/SQL/*.sql from my extension. 我最终使用了您提到的挂钩,并使其从扩展中读取并执行所有Configuration/SQL/*.sql
  • There is a way to modify SQL schema at runtime but it is limited to the usual CREATE TABLE (pseudo) statements. 有一种在运行时修改SQL模式的方法,但仅限于通常的CREATE TABLE (伪)语句。 Use signal TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService - tablesDefinitionIsBeingBuilt for this. tablesDefinitionIsBeingBuilt ,请使用信号TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService - tablesDefinitionIsBeingBuilt It is used in TYPO3 core in TYPO3\\CMS\\Core\\Category\\CategoryRegistry::addCategoryDatabaseSchemaToTablesDefinition TYPO3\\CMS\\Core\\Category\\CategoryRegistry::addCategoryDatabaseSchemaToTablesDefinition中的TYPO3核心中使用它
  • Maybe TYPO3's switch to doctrine/dbal will change the situation. 也许TYPO3转换为学说/ dbal会改变这种情况。 As you can see , migration's under way… 如您所见 ,迁移正在进行中……

Be aware that there's no way to teach install tool's database analyzer your views so it will keep nagging you about removing them. 请注意,无法教您安装工具的数据库分析器您的视图,因此它将一直困扰您删除视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM