The purpose of the Admin module is to manage the the creation of the database user and the blank database to be used by the application.
Admin can be used to:
The API for the Admin module can be found at Annex B.
The Admin interface is initialised as describes in DBManager using the setMode() command.
$result = $dbmanager->setMode('admin');
The Admin interface provides the following generic commands.
The getVersion() command returns a string containing the DBMS version. It is called as follows:
$result = $dbmanager->getAdminDriver()->getDBVersion();
In this case $result should be a php string containing the version information of the connected database. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
The Admin interface provides the following command used to manipulate database users:
The userExists() command is used to test if the user that is to own the database exists or not. It has the following parameter:
The userExists() function is called as follows:
$result = $dbmanager->getAdminDriver()->userExists("username");
In this case $result should be true if the user exists or false if the user does not exist. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
Users are created using the createUser() command. It has the following parameters:
Note: If $unittestdb is true then the created user has additional rights which allow them to create and drop both databases and database users.
The createUser() function is called as follows:
// Create a user for testing
$result = $dbmanager->getAdminDriver()->createUser($username, $password, true);
// Create a normal user
$result = $dbmanager->getAdminDriver()->createUser($username, $password);
In both cases $result should be true if the user is created. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
The dropUser() command is used to delete a database user that is no longer required. It has the following parameter:
The dropUser() function is called as follows:
$result = $dbmanager->getAdminDriver()->dropUser("username");
$result should be true if the user is deleted. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
The Admin interface provides the following command used to manipulate databases:
The databaseExists() command is used to test if a database already exists. It has the following parameter:
The databaseExists() function is called as follows:
$result = $dbmanager->getAdminDriver()->databaseExists("databasename");
In this case $result should be true if the database exists or false if the database does not exist. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
The createDatabase() command is used to create a new database. It has the following parameters:
The createDatabase() function is called as follows:
$result = $dbmanager->getAdminDriver()->createDatabase("databasename", "username");
In this case $result should be true if the database is created or exists. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.
The dropDatabase() command is used to delete an existing database. It has the following parameter:
The dropDatabase() function is called as follows:
$result = $dbmanager->getAdminDriver()->dropDatabase("databasename");
In this case $result should be true if the database is deleted. If the command has failed then $result will be an object of type \g7mzr\db\common\Error.