0

I have a simple form that allows users to select an option from a select menu and then save it in the database. I need to store the full name so that views can use it. So the table in my database might look like this:

nid | uid | type
------------------
1   | 2   | 0
2   | 2   | 3
1   | 3   | 5
3   | 1   | 4

and so on... I was thinking of doing a basic one to many relationship table like:

tid | name
----------
0   | random name 1
1   | random name 2
2   | random name 3
3   | random name 4

but I only have 6-7 types at the most, so I'm not sure if that is efficient. Maybe simply storing the full name instead of an ID would be better in that case? Another way might be to use variable_get, but then I also need the custom field module that allows php code in views. Any better way to do it in drupal? Thanks.

4

2 回答 2

1

我会通过将术语放入分类法并在CCK节点类型中使用该分类法来做到这一点。通过清除正文标签关闭正文字段并使用auto nodetitle关闭标题字段。这样一来,该类型的节点添加表单就只是分类术语的选择列表,并且所有保存的节点都暴露在视图中,并且可以按用户和/或术语进行过滤。

这将为您提供一个看起来很像您所描述的数据库,但您永远不会注意到额外的开销,因为 Drupal 缓存了所有内容。

于 2010-01-22T01:08:48.417 回答
0

更好,因为“一段时间后”需要更少的支持......而且我认为性能不会那么不同,而不是保持在现场。还可以节省内存,因为 stings 只存储在小表格中,并且引用数字不需要太多的地方......

于 2010-01-22T04:18:55.820 回答