使用 PHP 驱动页面文本数据库 - 2 个问题
诸如“请输入您的姓名”等错误消息是所有用户表单和字段的一部分,这些错误消息是否存储在单独的错误消息表中还是主页文本表的一部分?我的设计是每个页面都有一个ID。页面上的每一行文本都有一个 ID。这是链接到页面的并且有一个共同的group_id。因此,在每次页面加载时,我都会调用组 id 的所有文本,以便在 1 次调用中加载所有页面文本。但我不确定错误消息的正常做法是什么,如果我应该在该组中调用它或再次点击数据库以从错误消息表中获取它。我也有多种语言,它们是链接到页面文本表的单独表格。
我的文本行是这样的。 “版权所有 @ 2011 ABC corp. 美国纽约州纽约市”,其中 ABC corp 是我主页的链接。因此,为了使这个文本数据库驱动,我有 3 个 PK id:
ID 1 = 版权所有@2011
ID 2 = ABC 公司
ID 3 = 纽约,纽约 - 美国
然后在代码中我可以将 html 链接添加到 ID 2。但这对于链接之间有大文本来说是一个主要问题。我无法将一个段落分成数百个 ID,只是为了容纳所有链接之间的内容。还能怎样做呢? (请注意,我也有多语言表,这与此无关)
平台:codeignitor / mysql
The error messages like "Please enter your name" etc. which are part of all the user forms and fields, are these stored in a separate error message table or are they part of the main page text table? My design is each page has an ID. Each line of text on the page has an ID. And this is linked to the page and has a common group_id. So on each page load I call all the text for the group id to load all page text in 1 call. But I am not sure what the normal practice is for error messages if i should call it in this group or hit the DB again to fetch it from an error message table. I have multi-language too which are seperate tables linking to the page text table.
My line of text is this. "Copyright @ 2011 ABC corp. New York, NY - USA" where ABC corp is a link to my homepage. So to make this text database driven I have 3 PK ids:
ID 1 = Copyright @ 2011
ID 2 = ABC corp.
ID 3 = New York, NY - USA
Then in the code i can add the html link to ID 2. but this is a major problem for large text with in between links. I cant break a paragraph into hundreds of IDs just to fit in all the in between links. How else to do it? (Do note i have multi-lang tables too which FK to this)
Platform: codeignitor / mysql
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)关于 保持语言环境的最佳方式有很好的建议PHP 中依赖的字符串资源?。这是关于本地化字符串的,但仍然适用于您有关存储字符串的问题。您可能想避免数据库连接,而只需要一个 PHP 文件“app_strings.php”(或其他文件)将所有界面文本加载为变量。
2)抱歉,我对后半部分没有多大帮助,我不太明白这个问题。
1) There is good advice on Best way of keeping locale-dependent string resources in PHP?. It's about localized strings, but still applies to your question about storing strings. You probably want to avoid the database connection and just have a PHP file "app_strings.php" (or whatever) that loads all your interface text as variables.
2) Sorry I'm not much help on the second half, I don't quite understand the question.