php - mysql 中语言字段的最佳类型?

标签 php mysql

我是 php 和 mysql 的初学者,我想开发一个多语言网站。在我的数据库中,我有一个用户表,用于存储用户信息,例如 id,password,access_type,language,...

我会使用char(2) 类型,但现在我认为它不能存储所有语言。我应该为语言字段使用什么类型?

我在这里写下我的其他字段类型,我很乐意知道您对它们的看法!
对于作为用户电子邮件的 id,我使用 varchar(255)
对于 password,我使用 varchar(255) 并保存 password_hash 方法返回的散列密码。
对于 access_type,我使用 char(2)。我对 super 用户使用 su,对业余用户使用 au
对于名字,我使用 varchar(32)
对于姓氏,我使用 varchar(32)

对不起我的英语,因为我的语言不是英语!!

最佳答案

you can use anything between 2 to 4 as per you requirement.better create a foreign key instance in some other table where you are having detailed information about the languages. for foreign key concept you can visit here:http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html

枚举也很方便。

关于php - mysql 中语言字段的最佳类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25342332/

相关文章:

php - 使用 fwrite 保存 .xls 文件

php - 无法登录 TeSTLink - 未保存 session /cookie

PHP:单击表单提交按钮时 session 变量丢失了吗?

PHP & MySQL 不更新数据库

javascript - 使用按钮显示/隐藏表单时遇到问题(PHP/HTML/Javascript)

php - 无法在 JavaScript 中访问 PHP 数组,初始化为数组的 JavaScript 对象在 Chrome 开发者工具中最终变为空

javascript - 对图像使用分页

php - 创建您自己的 Paypal 请求

php - 从MySQL获取最低用户总数和最高用户总数

mysql - 在laravel中使用unique(),mysql是否正确运行onDelete Cascade?