Question

I'm thinking about some database management system, and my question is simple :

Is there a simple and reliable way to retrieve the access rights (write, readonly etc.), by a PHP code?

I haven't wrote any code yet, as this is just in my mind for now, that will just help me to structure some tables.

Was it helpful?

Solution

All database permissions are stored in a default mysql database: information_schema. Simply create a MySQL user who has permissions to view entries in this table, and use this user's login credentials when connecting from a PHP script. You can the retrieve permissions from the various permissions tables (which include DB level, table level, and column level permissions) to report back user rights. Something like:

SELECT * FROM`information_schema`.`user_privileges` WHERE`grantee` LIKE"'user'%";

Once you've run this query you can format the results however you'd like in PHP.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top