gpt4 book ai didi

mysql - 如何检查用户是否有权限?

转载 作者:行者123 更新时间:2023-11-30 01:00:32 26 4
gpt4 key购买 nike

我有两个表(用户和权限)。如何查看用户是否有权限?在这种情况下编辑主题的权限

1是管理员帐户

表格:用户(id、用户名、acc_type) (1, 米尔索, 1)

权限(id、名称、描述、acc_type、permission_key) (1,主题编辑,一些文字,1,edit_topic)

最佳答案

您正在寻找SHOW GRANTS Syntax

SHOW GRANTS displays only the privileges granted explicitly to the named account. Other privileges might be available to the account, but they are not displayed. For example, if an anonymous account exists, the named account might be able to use its privileges, but SHOW GRANTS will not display them.

你可以尝试这样:

Show grants for myuser;

编辑:-

对此不太确定,但您可以尝试一下:

<?php
$db = mysql_connect('Database_Address','database_user','database_password');
if ($db === false) {
die("mysql_connect error: " . mysql_error());
}
$selected = mysql_select_db('Database', $db);
if ($selected === false) {
die("mysql_select_db error: " . mysql_error());
}

关于mysql - 如何检查用户是否有权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20173191/

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