cakephp - 手动为没有表的模型创建记录
我需要几个模型,但由于每个模型的数据大小不超过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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说听起来像是某种枚举。
如果是(变化不大或者不需要前端来添加/编辑/删除),您可以将其放入模型代码中并使用类似的东西
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.
您可以使用 数组数据源< /a> 它的一个优点是您可以将其视为模型(链接到其他模型,执行 find() 查询等)
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.)