TYPO3扩展生成器外键 [英] TYPO3 Extension Builder Foreign Key

查看:196
本文介绍了TYPO3扩展生成器外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么TYPO3扩展生成器不生成外键?



我在模型之间设置了一些关系,但是在SQL代码中只有FKs colums for the key。



有没有人可以帮助我?

解决方案


这是一个半意识的设计决策。只要查看在MySQL中引入的
外键约束的日期,并比较
TYPO3是天生的。

当然,添加这样的引用是非常好的,特别是因为
MySQL总是可以处理它们,即使底层存储引擎
没有处理它们(在这种情况下它们将被忽略) p>



到现在为止没有任何变化,所以您需要在建模之后自行创建外键。



回答评论:


您是如何处理两者之间的关系表?例如我有一个桌子与房子有关的桌子的人们


这取决于关系类型当然 1:n n:1 m:n 等)和Builder支持建模工具完美的关系。请记住,在TYPO3中保持关系不需要外键。

在文档的TCA部分中有一些规则,即在提到的情况下,您可以使用
select group(with internal_type) 字段类型。对于多对多的关系,你也需要创建MM表。如果您遵循这些文档,您可以确定,在常见的后端编辑表单中,它们将被正确处理。



如前所述,Extension Builder支持创建不同类型的在其点击式建模工具中的关系,值得花一些时间来看看TYPO3中不同类型的关系是如何处理的。它使用与在 pre-extbase 扩展中创建关系时相同的规则。更重要的是,Builder为模型添加了必要的方法,例如获取附加 code>给定关系字段的MM对象,因此在开始时建模所有关系是最重要的。在其他情况下,你需要手动编写这些方法(这是无聊的过程)

Why does the TYPO3 Extension Builder don't generate Foreign keys?

I've set some relations between the models, but in SQL Code there are noe FKs only colums for the Value of the key.

Does anyone can help me?

解决方案

Cite from Kartsen Dambekalns

It is a half-conscious design decision. Just look up the date when foreign key constraints where introduced in MySQL, and compare to when TYPO3 was 'born'.

Of course it would be great to add such references, especially since MySQL can always handle themm, even if the underlying storage engine doesn't handle them (in case of which they'll just be ignored).

(source)

Nothing changed till now, so you need to create foreign keys yourself after modeling.

Answer to comment:

how did you handle the relations between two tables? for example I've got a table people which relates to the table house with the column housenr

That depends on relation type of course (1:n, n:1, m:n, etc) and Builder supports creating relations in modeling tool perfectly. Keep in mind, that foreign keys are NOT required for keeping relations in TYPO3.

There are some rules described in TCA section of documentation, i.e. in mentioned case you can use select or group (with internal_type) type of field. For many-to-many relation also you'll need to create MM table. If you'll follow these documents, you can be sure, that in common backend editing form they will be handled properly.

As mentioned before Extension Builder supports creating different types of relations in its click-click modeling tool and it's worthy to spend some time to play with it to see how relations of different types are handled in TYPO3. It uses the same rules that are used in creating relations also in pre-extbase extensions. What's more Builder adds required methods to the models i.e. for getting, attaching and detaching MM objects of given relation field, therefore it's most important to model all your relations at start. In other case you'll need to write these methods manually (which is boring process)

这篇关于TYPO3扩展生成器外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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