Create a new MySQL Database.

@param  integer $serverId
@param  array $data
@param  boolean $wait
@return MysqlDatabase
483718
public function createMysqlDatabase($serverId, array $data, $wait = true)
    {
        $database = $this->post("servers/$serverId/mysql", $data)['database'];

        if ($wait) {
            return $this->retry($this->getTimeout(), function () use ($serverId, $database) {
                $database = $this->mysqlDatabase($serverId, $database['id']);

                return $database->status == 'installed' ? $database : null;
            });
        }

        return new MysqlDatabase($database + ['server_id' => $serverId], $this);
    }
1332629
public function destroySiteGitRepository($serverId, $siteId, $wait = true)
    {
        $this->delete("servers/$serverId/sites/$siteId/git");

        if ($wait) {
            $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
                return is_null($this->site($serverId, $siteId)->repositoryStatus);
            });
        }
    }
508903
public static function create( $sql, $parameters = null, $connection = null, $fetchMode = \PDO::FETCH_ASSOC )
    {
        $_reader = new DataReader( Sql::createStatement( $sql, $connection, $fetchMode ) );

        if ( false === ( $_result = $_reader->execute( $parameters ) ) )
        {
            //	Don't be wasteful
            unset( $_reader );

            return false;
        }

        return $_reader;
    }
52698
public function installGitRepositoryOnSite($serverId, $siteId, array $data, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/git", $data);

        if ($wait) {
            $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
                return $this->site($serverId, $siteId)->repositoryStatus === 'installed';
            });
        }
    }
62840
protected function insertTableData(& $data, $useQueue = true)
    {
        $job = new DBInsert($this->service->getName(), $this->resource, $data);
        if ($useQueue !== true) {
            $job->onConnection('sync');
        }

        dispatch($job);
        $data = [];
    }
105409
public function create($data, $disputeId = null)
    {
        if (isset($disputeId)) {
            return $this->client()->put($data, 'disputes/{disputeId}', ['disputeId' => $disputeId]);
        }

        return $this->client()->post($data, 'disputes');
    }
161929
protected function createConnection( $driver, $connection, $database, $prefix = '', array $config = [] )
	{
		switch ( $driver )
		{
			case 'mysql':
				return new MySqlConnection( $connection, $database, $prefix, $config );
			case 'pgsql':
				return new PostgresConnection( $connection, $database, $prefix, $config );
			case 'sqlite':
				return new SQLiteConnection( $connection, $database, $prefix, $config );
			case 'sqlsrv':
				return new SqlServerConnection( $connection, $database, $prefix, $config );
		}

		throw new InvalidArgumentException( "Unsupported driver [$driver]" );
	}
1002490
protected function createMySQLDatabase()
    {
        $this->checkParameters();
        $this->url = $this->obtainAPIURLEndpoint();
        try {
            $this->http->post($this->url, [
                    'form_params' => $data = $this->getData(),
                    'headers' => [
                        'X-Requested-With' => 'XMLHttpRequest',
                        'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
                    ]
                ]
            );
            if ($this->option('wait')) {
                $this->info('Waiting for database to be installed in Laravel Forge server...');
                $this->waitForMySQLDatabaseByName($data['name']);
                $this->info('Installed!');
            }
        } catch (\GuzzleHttp\Exception\ServerException $se) {
            if (str_contains($se->getResponse()->getBody()->getContents(), 'The given data failed to pass validation')) {
                $this->error('Skipping installation. Some of the data you provided already exists in server');
            }
        } catch (\Exception $e) {
            dump($e->getMessage());
        }
    }
39010
final public function insert(array $datas, bool $returning_id = false) {
      if (is_array($datas) && count($datas)) {
         if (!is_array(@$datas[0]))
            $datas = [$datas];

         $this->connection();
         $this->columns();

         $placeholders = [];
         $this->placeholder_data = [];

         foreach ($datas as $data) {
            $placeholder = [];
            foreach($this->columnsData as $column) {
               if(isset($data[$column])) {
                  $placeholder[$column] = "NULL";
                  if ( gettype($data[$column])==='boolean' )
                     $placeholder[$column] = $data[$column] ? 'TRUE' : 'FALSE';
                  elseif ( $data[$column]!=='' && $data[$column]!==NULL ) {
                     $placeholder[$column] = "?";
                     $this->placeholder_data[] = $data[$column];
                  }
               }
            }
            $placeholders[] = "(".implode(",", $placeholder).")";
         }

         $columns = "(".implode(",", array_keys($placeholder)).")";

         $placeholders = implode(",", $placeholders);


         $schema = '';
         $returning = '';
         if ($this->driver=='pgsql' && $this->schema) {
            if (!preg_match('/\./', $this->table)) {
               $schema = $this->schema ? $this->schema.'.' : '';	
            }
            $returning = $returning_id ? 'RETURNING '.$this->primaryKey : '';
         }

         $this->last_sql = $this->sql = "INSERT INTO {$schema}{$this->table} {$columns} VALUES {$placeholders} {$returning};";
         
         $this->fetch();

         $this->data = $this->rows;

         $this->reset();

         if ( $this->tableOrig!==NULL ) {
            $this->table = $this->tableOrig;
         }

         $error = $this->error();
         return $error['message'] ? FALSE : TRUE;
      }
      return FALSE;
   }
1090517
public function loadData($writerId, array $tables, $incrementalLoad = null, $queue = 'primary')
    {
        $job = $this->loadDataAsync($writerId, $tables, $incrementalLoad, $queue);
        if (!isset($job['url'])) {
            throw new ServerException('Load data job returned unexpected result: ' . json_encode($job, JSON_PRETTY_PRINT));
        }

        return $this->waitForJob($job['url']);
    }
312240
public static Connection createSpatialDataBase(String dbName, boolean initSpatial )throws SQLException, ClassNotFoundException {
        return createSpatialDataBase(dbName, initSpatial, H2_PARAMETERS);
    }
103137
protected function waitForMySQLDatabaseByName($database_name)
    {
        return $this->retry(50, function () use ($database_name) {
            $this->databases = $this->fetchMySQLDatabases();
            $database = $this->getMysqlDatabaseByName($this->databases, $database_name);
            return $database['status'] == 'installed' ? $database : null;
        });
    }
464108
public static function createMemcachedStore( array $servers = array(), $persistentId = null, $callback = null )
    {
        if ( !extension_loaded( 'memcached' ) )
        {
            throw new \LogicException( 'The PHP "Memcached" extension is required to use this store type.' );
        }

        return new static(
            CacheTypes::MEMCACHED, array(
                'servers'       => $servers,
                'persistent_id' => $persistentId,
                'callback'      => $callback,
            )
        );
    }
1082621
public function createFirewallRule($serverId, array $data, $wait = true)
    {
        $rule = $this->post("servers/$serverId/firewall-rules", $data)['rule'];

        if ($wait) {
            return $this->retry($this->getTimeout(), function () use ($serverId, $rule) {
                $rule = $this->firewallRule($serverId, $rule['id']);

                return $rule->status == 'installed' ? $rule : null;
            });
        }

        return new FirewallRule($rule + ['server_id' => $serverId], $this);
    }
623612
public function create($data, $listId = null)
    {
        if (isset($listId)) {
            return $this->client()->put($data, 'lists/{listId}', ['listId' => $listId]);
        }

        return $this->client()->post($data, 'lists');
    }
848331
public static DataSource createDataSource(String dbName ,boolean initSpatial, String h2Parameters) throws SQLException {
        // Create H2 memory DataSource
        org.h2.Driver driver = org.h2.Driver.load();
        OsgiDataSourceFactory dataSourceFactory = new OsgiDataSourceFactory(driver);
        Properties properties = new Properties();
        String databasePath = initDBFile(dbName, h2Parameters);
        properties.setProperty(DataSourceFactory.JDBC_URL, databasePath);
        properties.setProperty(DataSourceFactory.JDBC_USER, "sa");
        properties.setProperty(DataSourceFactory.JDBC_PASSWORD, "sa");
        DataSource dataSource = dataSourceFactory.createDataSource(properties);
        // Init spatial ext
        if(initSpatial) {
            try (Connection connection = dataSource.getConnection()) {
                H2GISFunctions.load(connection);
            }
        }
        return dataSource;
    }
1156761
public void add_server(Database database, String serverName, DbDevInfo[] devinfo)
            throws DevFailed {
        if (!database.isAccess_checked()) checkAccess(database);

        //	Convert data from DbDevInfos to a string array
        //----------------------------------------------
        //System.out.println("creating " + serverName);
        String[] array;
        array = new String[1 + 2 * devinfo.length];

        array[0] = serverName;
        for (int i = 0 ; i<devinfo.length ; i++) {
            array[2 * i + 1] = devinfo[i].name;
            array[2 * i + 2] = devinfo[i]._class;
        }

        //	Send command
        //-----------------------
        DeviceData argIn = new DeviceData();
        argIn.insert(array);
        command_inout(database, "DbAddServer", argIn);
    }