phpmyadmin 中的枚举值可以是这样的吗? “自述文件”=>1
在此,我会看到自述文件,但该值将设置为 1
这可能吗?
编辑; 对不起。基本上我有一个网站。它的导航位于数据库中。它需要根据用户状态显示导航项,例如登录、管理员、博客、未登录和独立。这些工作,但是我想从数值转向人类可读的。我想保持我的脚本不变。那么,基本上,我可以让 enum Test 等于 1,就像 php 数组一样吗?
In this, I would see Readme, but the value would be set to 1
Is this possible?
edit;
Sorry. Basically I have a site. It's navigation is in the database. It need to display nav items depening on the users state, like, logged in , admin, blogger, not loggin, and indepenant. These work, however I would like to move from numerical values to human readable. I would like to keep my script the same. So, basicly, can I make the enum Test equal to 1, like a php array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的接口无法将符号名称分配给您所描述的值。
但是,您可以使用查找表,以便将字符串名称与每个数值相关联。也就是说,您可以继续在数据库表中存储 -1、0、1、2、3 等值,但您需要创建另一个表来将这些值映射到字符串中。然后,当您想要显示人类可读的名称时,您可以将其作为查找表的联接来执行。
The interface you're using has no way of assigning symbolic names to values like you describe.
However, you can use a lookup table so you can associate a string name with each numeric value. That is, you can continue to store values like -1, 0, 1, 2, 3 in your database table, but you would create another table to map those values into strings. Then when you want to show the human-readable names, you would do that as a join to the lookup table.