本文介绍了CakePHP在代码级别处理FKs,还是应该添加FKs到我的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我添加FKs与ON DELETE CASCADE等等,我会遭受后果吗?



如果不是,我应该使用MySQL中的FKs CakePHP ?

解决方案

您可以看到和通过命名约定的隐含关联。您可以通过在数据库级定义FK关系来添加额外的强制层。如果你的数据库荣誉这些,它是更难射击自己在脚,但它不是必要的。它增加了在Cake的模型和数据库中保持关系同步的额外开销。


Will I suffer consequences later if I add FKs with ON DELETE CASCADE and such?

If not, what naming convention should I be using for FKs within MySQL for CakePHP?

解决方案

You can see the naming conventions laid out here.

Cake handles FK/relationships in the code, based on your model associations and implied associations by naming conventions. You can add an extra layer of "enforcement" by defining FK relationships on the database level. If your database honours these, it's harder to shoot yourself in the foot, but it's not necessary. It adds the extra overhead of keeping the relationships in sync in Cake's models and in the database.

这篇关于CakePHP在代码级别处理FKs,还是应该添加FKs到我的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:48