我正在为教师开发一个webapp,可能有数百个用户,每个用户可以创建十个左右的模板,其中十个左右的部分有十个左右的主题,每个主题都有一段文本的长短版本。
这将导致像这样的多维数组:
[userID][templates][1][name] // template 1 name
[userID][templates][1][1][name] // template 1 section 1 name
[userID][templates][1][1][1][name] // template 1 section 1 topic 1 name
[userID][templates][1][1][1][1][short] // template 1 section 1 topic 1 option 1 short
[userID][templates][1][1][1][1][long] // template 1 section 1 topic 1 option 1 long
每个数字可能会有所不同(最多约10个)。 'name'元素只代表用户友好的名称。
模板元素之外可能还有其他一些设置。 只需要存储和检索文本。存储和检索此数据的最简单方法是什么。我是否需要创建数千个mySQL表(这种方式太多了?我最多只使用过5个)还是有更直接的方式?
答案 0 :(得分:3)
将其写入您可以存储的字符串:$string = serialize($array)
将其读回对象/数组$array = unserialize($string)