gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 00:10:31 25 4
gpt4 key购买 nike

我是 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com