Acquia\Cloud\Api\CloudApiClient::addDatabase PHP Метод

addDatabase() публичный метод

См. также: http://cloudapi.acquia.com/#POST__sites__site_dbs-instance_route
public addDatabase ( string $site, string $db, array $cluster_map = NULL ) : Acquia\Cloud\Api\Response\Task
$site string
$db string
$cluster_map array Optional. A mapping containing all environments and the cluster to which the associated database should be created. Each entry consists of the environment name as the key and the database cluster ID as the value. Note that if more than one cluster is associated with a site group, this map is required.
Результат Acquia\Cloud\Api\Response\Task
    public function addDatabase($site, $db, $cluster_map = NULL)
    {
        $variables = array('site' => $site);
        $options = array();
        if (is_array($cluster_map) && !empty($cluster_map)) {
            foreach ($cluster_map as $env => $db_cluster) {
                if (is_string($env) && !empty($env) && intval($db_cluster) > 0) {
                    $options[$env] = array('db_cluster' => (string) $db_cluster);
                }
            }
        }
        $body = array('db' => $db);
        if (count($options) > 0) {
            $body['options'] = $options;
        }
        $body = Json::encode($body);
        $request = $this->post(array('{+base_path}/sites/{site}/dbs.json', $variables), null, $body);
        return new Response\Task($request);
    }