PHP涉及数据库内容的多语言设计怎么实现

WBOY
Release: 2016-06-13 12:15:59
Original
1481 people have browsed it

PHP涉及数据库内容的多语言设计如何实现?
请问有人做过么?(就类似APPLE的官网的内容多语言切换)能不能帮一下忙,谢谢了
------解决思路----------------------
表中字段加多語言。
例如:
sc_title, en_title, tc_title
------解决思路----------------------
语言改变不改动数据库的做法
table: res (id, ...)
table: res_lang (id, res_id, 语言, 内容...)
------解决思路----------------------

引用:
增加语言难道要增加表吗?
增加表就不是改动数据库了吗?

Quote: 引用:

语言改变不改动数据库的做法
table: res (id, ...)
table: res_lang (id, res_id, 语言, 内容...)


这个用法不需要增加表,以上
------解决思路----------------------
不用加字段,也不用加标,这样设计表
我之前是这样做的:

<br />CREATE TABLE `article` (<br />  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,<br />  `albumID` int(11) DEFAULT NULL,<br />  `category` mediumint(8) unsigned NOT NULL DEFAULT '0',<br />  `title` varchar(120) NOT NULL,<br />  `uid` int(10) unsigned NOT NULL DEFAULT '0', <br />  `description` mediumtext NOT NULL,<br />  `content` text NOT NULL, <br />  `puttime` int(10) unsigned NOT NULL DEFAULT '0', <br />  `listorder` int(10) unsigned NOT NULL DEFAULT '999', <br />  `lang` varchar(20) NOT NULL DEFAULT 'zh_cn',<br />  PRIMARY KEY (`id`),<br />  KEY `category` (`category`),<br />  KEY `lang` (`lang`) <br />) ENGINE=MyISAM AUTO_INCREMENT=5961 DEFAULT CHARSET=utf8<br /><br />
Copy after login



其中lang字段用来标识不同语言,所有语种的都保存到这个表
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!