Add list users command
This commit is contained in:
@ -29,7 +29,7 @@ class DatabaseManager
|
||||
public function createDatabase(string $name)
|
||||
{
|
||||
$dbs = $this->listDatabases();
|
||||
if(in_array($name, $dbs)) {
|
||||
if (in_array($name, $dbs)) {
|
||||
throw new \Exception(sprintf('Database "%s" already exists', $name));
|
||||
}
|
||||
|
||||
@ -38,4 +38,20 @@ class DatabaseManager
|
||||
throw new \Exception(sprintf('Database create error: %s', $this->conn->error));
|
||||
}
|
||||
}
|
||||
|
||||
public function listUsers(): array
|
||||
{
|
||||
$results = $this->conn->query('select * from mysql.user');
|
||||
|
||||
$users = [];
|
||||
while ($result = $results->fetch_object()) {
|
||||
$users[] = [
|
||||
'name' => $result->User,
|
||||
'host' => $result->Host,
|
||||
'plugin' => $result->plugin,
|
||||
];
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user