Acquia\CloudApi\Client\CloudApi::addDatabase PHP Method

addDatabase() public method

Add a database
public addDatabase ( $site, $db, $cluster_map = NULL )
$site the site name (ex: tangle001, gardener, etc.)
$db the database name
$cluster_map a mapping containing all environments and the cluster to which the associated database should be created. (See getDatabaseClusterMap). Note that if more than one cluster is associated with a sitegroup, this map is required.
    public function addDatabase($site, $db, $cluster_map = NULL)
    {
        $method = 'POST';
        $resource = sprintf('/sites/%s/dbs', $this->getSiteName($site));
        $body = array('db' => $db);
        if (!empty($cluster_map)) {
            $body['options'] = array();
            foreach ($cluster_map as $env => $db_cluster) {
                $body['options'][$env] = array('db_cluster' => (string) $db_cluster);
            }
        }
        $result = $this->callAcapi($site, $method, $resource, array(), $body);
        return $result['result'];
    }