} if (!$server_found) { throw new Exception("Couldn't find mysql database server"); } echo "Database server found: " . $data['db_server_id'] . "<BR>"; /* * 25. Create database (CreateDatabase) */ $request = new \pmill\Plesk\CreateDatabase($config, array('name' => random_string(), 'subscription_id' => $data['subscription_id'], 'server_id' => $data['db_server_id'], 'type' => 'mysql')); $info = $request->process(); $data['db_id'] = $request->id; echo "Database created: " . $data['db_id'] . "<BR>"; /* * 26. List databases (ListDatabases) */ $request = new \pmill\Plesk\ListDatabases($config, array('subscription_id' => $data['subscription_id'])); $databases = $request->process(); $database_found = false; foreach ($databases as $database) { if ($database['id'] == $data['db_id']) { $database_found = true; } } if (!$database_found) { throw new Exception("Couldn't find created database"); } echo "Database found: " . $data['db_id'] . "<BR>"; /* * 27. Create database user (CreateDatabaseUser) */ $data['db_user_username'] = random_string();
<?php require_once "../config.php"; /* * Lists all database under a subscription */ $params = array('subscription_id' => 0); $request = new \pmill\Plesk\ListDatabases($config, $params); $info = $request->process(); var_dump($info);