Add command to create database
This commit is contained in:
@ -25,4 +25,17 @@ class DatabaseManager
|
||||
|
||||
return $dbs;
|
||||
}
|
||||
|
||||
public function createDatabase(string $name)
|
||||
{
|
||||
$dbs = $this->listDatabases();
|
||||
if(in_array($name, $dbs)) {
|
||||
throw new \Exception(sprintf('Database "%s" already exists', $name));
|
||||
}
|
||||
|
||||
$result = $this->conn->query(sprintf('CREATE DATABASE `%s`', $name));
|
||||
if (!$result) {
|
||||
throw new \Exception(sprintf('Database create error: %s', $this->conn->error));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user