cakephp - 手动为没有表的模型创建记录

发布于 2024-11-28 13:44:49 字数 82 浏览 1 评论 0原文

我需要几个模型,但由于每个模型的数据大小不超过5条记录,因此使用db-table似乎很浪费。 我该怎么办?

这些模型应该与其他模型链接

I need several models, but since the data size is not more than 5 records each, it seems like a waste to use db-table.
how should I do it?

these models are supposed to be linked to other models

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

路弥 2024-12-05 13:44:49

对我来说听起来像是某种枚举。
如果是(变化不大或者不需要前端来添加/编辑/删除),您可以将其放入模型代码中并使用类似的东西
http://www.dereuromark.de/2010/ 06/24/static-enums-or-semihardcoded-attributes/

如果您需要一个 CRUD 后端来在线编辑它,您可以将它们分组一起形成一个可能称为“list_items”的模型,其中带有“type”字段来区分您正在讨论的不同模型。这样,您就有一个模型保存所有这些枚举,并且您可以为用户/管理员提供添加/编辑/删除访问权限。

sounds like some kind of enum to me.
if it is (does not change very much or does not need a frontend to add/edit/delete) you can put it in the model code and use sth like
http://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/

if you need to have a crud backend for it to edit it online you could group them together to a model maybe called "list_items" with a "type" field to distinguish the different models you are talking about. this way you have one model holding all those enums and you can provide add/edit/delete access for them for users/admins.

め可乐爱微笑 2024-12-05 13:44:49

you can use array datasource One advantage of it is you can treat it like a model (linking to other models, do find() query, etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文