TYPO3 Extension Builder Foreign Key

試著忘記壹切 提交于 2019-12-11 07:12:39

问题


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?


回答1:


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)



来源:https://stackoverflow.com/questions/27603373/typo3-extension-builder-foreign-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!