createDatabase

@param string $name
@param bool   $isNotExists
@param string $charset
@param string $collate

@return  string
179263
public static function createDatabase($name, $isNotExists = false, $charset = null, $collate = null)
    {
        $query = static::getQuery();

        return static::build(
            'CREATE DATABASE',
            $isNotExists ? 'IF NOT EXISTS' : null,
            $query->quoteName($name),
            $charset ? 'CHARACTER SET=' . $query->quote($charset) : null,
            $collate ? 'COLLATE=' . $query->quote($collate) : null
        );
    }
391057
public function create($ifNotExists = false, $charset = 'utf8', $collate = 'utf8_unicode_ci')
    {
        $query = MysqlGrammar::createDatabase($this->name, $ifNotExists, $charset, $collate);

        $this->db->setQuery($query)->execute();

        return $this;
    }
298551
public static function createDatabase($name, $encoding = null, $owner = null)
    {
        $query = static::getQuery();

        return static::build(
            'CREATE DATABASE',
            $query->quoteName($name),
            $encoding ? 'ENCODING ' . $query->quote($encoding) : null,
            $owner ? 'OWNER ' . $query->quoteName($owner) : null
        );
    }
70092
public function createDatabase($dbName = null)
    {
        if (is_null($dbName)) {
            $dbName = $this->getDbName();
        }

        $dbName = str_replace('`', '', $dbName);

        Db::exec("CREATE DATABASE IF NOT EXISTS `" . $dbName . "` DEFAULT CHARACTER SET utf8");
    }
225388
public static function createDatabase()
  {
      $ddl = file_get_contents('verbs.sql');
      if (file_exists('verbs.db')) {
          unlink('verbs.db');
      }
      $connection = new PDO('sqlite:verbs.db');
      $connection->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
      $connection->exec($ddl);

      $entries = simplexml_load_file('JMdict');
      if ($entries === false) {
        echo 'Could not open JMdict file' . PHP_EOL;
      }

      $connection->beginTransaction();
      $sql = 'INSERT INTO verbs (kanji, kana, type) VALUES (:kanji, :kana, :type)';
      $statement = $connection->prepare($sql);

      foreach ($entries as $entry) {
        $poses = [];
        foreach ($entry->xpath('sense/pos') as $pos) {
          $poses[] = array_keys(get_object_vars($pos))[0];
        }

        foreach ($poses as $pos) {
          if (stripos($pos, 'v1') !== false || stripos($pos, 'v5') !== false || $pos == 'vz' || $pos == 'vk' || $pos == 'vn' || $pos == 'vr' || $pos == 'vs-s' || $pos == 'vs-i') {
            $kanji = $entry->k_ele->keb;
            $kana = $entry->r_ele->reb;
            $saved = $statement->execute(array(':kanji' => $kanji, ':kana' => $kana, ':type' => $pos));
            if ($saved === false) {
              die('Could not save entry : ' . implode(' ', $statement->errorInfo()));
            }
          }
        }
      }
      $connection->commit();
  }
153335
public function createDatabase(
        string $dbName,
        string $characterSet = 'utf8mb4',
        string $collate = 'utf8mb4_unicode_ci'
    ): bool {
        $sql = 'CREATE DATABASE %s CHARACTER SET %s COLLATE %s;';
        $sql = vsprintf($sql, [
            $this->quoter->quoteName($dbName),
            $this->quoter->quoteValue($characterSet),
            $this->quoter->quoteValue($collate),
        ]);

        return $this->db->exec($sql);
    }
276970
public function getDatabase($name = null, $new = false)
    {
        $name = $name ?: $this->database;

        if (empty($this->databases[$name]) || $new) {
            $class = sprintf(
                'Windwalker\\Database\\Driver\\%s\\%sDatabase',
                ucfirst($this->name),
                ucfirst($this->name)
            );

            if (!class_exists($class)) {
                throw new \InvalidArgumentException(sprintf('Class %s not exists.', $class));
            }

            $this->databases[$name] = new $class($name, $this);
        }

        return $this->databases[$name];
    }
173283
public static function createMigration(string $name): void
    {
        $directory = Application::getApplicationPath('migrations');

        if (!is_dir($directory)) {
            Directory::mkdir($directory, 0755);
        }

        $timestamp = time();
        $className = Util::camelCase($name, null, false);
        $phpClassName = "Migration_{$timestamp}_{$className}";
        $fileName = "{$timestamp}_{$className}.php";
        $fullPath = Application::getApplicationPath("migrations/{$fileName}");

        $migrationFileContent = file_get_contents(__DIR__ . '/MigrationTemplate.php');
        $migrationFileContent = str_replace('templateClassName', $phpClassName, $migrationFileContent);
        $migrationFileContent = str_replace('templateClassGenerated', date('r'), $migrationFileContent);

        if (file_put_contents($fullPath, $migrationFileContent) === false) {
            throw new Application\Exception("Unable to write to migration file on path={$fullPath}");
        }

        Log::info("Created DB migration with name: {$name}");
        Log::info("You may now open application/migrations/{$fileName} and add your migration code");
    }
297527
protected function createDatabase()
    {
        /** @var Container $container */
        $container = $this->console->container;

        $dbService = $container->get(DatabaseService::class);
        $config    = $dbService->getDbConfig();

        // Auto create database
        $name = $config['name'];

        $config['name'] = null;

        $db = $dbService->createConnection('_preset', $config->toArray());

        $db->getDatabase($name)->create(true);

        $db->select($name);

        $config['name'] = $name;
    }
603287
public function createTable($name, $data)
    {
        $q = "CREATE TABLE {$name} (";
        foreach ($data as $key => $v) {
            $q .= $key;

            if (isset($v['type'])) {
                $q .= " {$v['type']}";
                if (isset($v['length'])) {
                    $q .= "({$v['length']})";
                } else {
                    if ($v['type'] != 'int' && $v['type'] != 'datetime') {
                        die ("Please set length for table: {$name} - column: {$key}");
                    }
                }

                if (isset($v['unsigned']) && $v['unsigned'] == true) {
                    $q .= " UNSIGNED";
                }

                if (!isset($v['null']) || $v['null'] == false) {
                    $q .= " NOT NULL";
                }

                if (isset($v['default'])) {
                    if (is_string($v['default'])) {
                        $v['default'] = "'{$v['default']}'";
                    }

                    $q .= " DEFAULT {$v['default']}";
                }

                if (isset($v['ai']) && $v['ai'] == true) {
                    $q .= " AUTO_INCREMENT";
                }

                if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) {
                    die ("Unique or Primary?");
                }

                if (isset($v['unique']) && $v['unique'] == true) {
                    $q .= " UNIQUE";
                }

                if (isset($v['primary']) && $v['primary'] == true) {
                    $q .= " PRIMARY KEY";
                }

                if (isset($v['foreign']) && isset($v['foreign']['table']) && isset($v['foreign']['column'])) {
                    $q .= " ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})";

                    if (isset($v['foreign']['delete']) && $v['foreign']['delete'] == true) {
                        $q .= " ON DELETE CASCADE";
                    }

                    if (isset($v['foreign']['update']) && $v['foreign']['update'] == true) {
                        $q .= " ON UPDATE CASCADE";
                    }
                }

                $q .= ", ";

            } else {
                die ("Please set type of column ");
            }
        }

        $q = substr($q, 0, -2);
        $q .= ")";

        return $this->executeQuery($q);
    }
939551
public function createLanguage(
        ?LanguageCreateData $data = null,
        ?string $name = null
    ): FormInterface {
        $name = $name ?: StringUtil::fqcnToBlockPrefix(LanguageCreateType::class);

        return $this->formFactory->createNamed(
            $name,
            LanguageCreateType::class,
            $data ?? new LanguageCreateData()
        );
    }
343035
public function createTable($name, callable $callback, $ifNotExists = true, $options = [])
    {
        $options = $this->prepareBCOptions($options);

        return $this->getTable($name)->create($callback, $ifNotExists, $options);
    }
1069682
private function createDatabase(
        OutputInterface $output,
        Connection $tmpConnection,
        string $name,
        bool $shouldNotCreateDatabase
    ): int {
        try {
            if ($shouldNotCreateDatabase) {
                $output->writeln(sprintf('<info>Database <comment>%s</comment> already exists.</info>', $name));
            } else {
                $tmpConnection->getSchemaManager()->createDatabase($name);
                $output->writeln(sprintf('<info>Created database <comment>%s</comment>', $name));
            }

            return 0;
        } catch (\Exception $e) {
            $output->writeln(sprintf('<error>Could not create database <comment>%s</comment></error>', $name));
            $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));

            return 1;
        }
    }
56787
public function createDatabase($name)
    {
        $response = $this->httpClient->request('PUT', '/'.urlencode($name));

        if ($response->status != 201) {
            throw HTTPException::fromResponse('/'.urlencode($name), $response);
        }
    }
115575
public static function createTable(
        $name,
        $columns,
        $pks = [],
        $keys = [],
        $inherits = null,
        $ifNotExists = true,
        $tablespace = null
    ) {
        $query = static::getQuery();
        $cols = [];

        foreach ($columns as $cName => $details) {
            $details = (array) $details;

            array_unshift($details, $query->quoteName($cName));

            $cols[] = call_user_func_array([get_called_class(), 'build'], $details);
        }

        if (!is_array($keys)) {
            throw new \InvalidArgumentException('Keys should be an array');
        }

        if ($pks) {
            $cols[] = 'PRIMARY KEY ' . static::buildIndexDeclare(null, (array) $pks, null);
        }

        $indexes = [];

        foreach ($keys as $key) {
            $define = [
                'type' => 'INDEX',
                'name' => null,
                'columns' => [],
                'comment' => '',
            ];

            if (!is_array($key)) {
                throw new \InvalidArgumentException('Every key data should be an array with "type", "name", "columns"');
            }

            $define = array_merge($define, $key);

            $indexes[] = 'CREATE ' . $define['type'] . ' ' . static::buildIndexDeclare(
                $define['name'],
                $define['columns'],
                $name
            );
        }

        $indexes = implode(";\n", $indexes);

        $cols = "(\n" . implode(",\n", $cols) . "\n)";

        return static::build(
            'CREATE TABLE',
            $ifNotExists ? 'IF NOT EXISTS' : null,
            $query->quoteName($name),
            $cols,
            $inherits ? 'INHERITS (' . implode(',', $query->quoteName((array) $inherits)) . ')' : null,
            $tablespace ? 'TABLESPACE ' . $query->quoteName($tablespace) : null,
            ";\n",
            $indexes ? $indexes : null
        );
    }
1355321
public function create($name, $start = 1, $nocache = false, $min = 1, $max = false, $increment = 1)
    {
        if (! $name) {
            return false;
        }

        if ($this->connection->getConfig('prefix_schema')) {
            $name = $this->connection->getConfig('prefix_schema') . '.' . $name;
        }

        $nocache = $nocache ? 'nocache' : '';

        $max = $max ? " maxvalue {$max}" : '';

        $sequence_stmt = "create sequence {$name} minvalue {$min} {$max} start with {$start} increment by {$increment} {$nocache}";

        return $this->connection->statement($sequence_stmt);
    }
98995
public function createDatabase($name, $charSet = null) {
		if ($charSet === null) {
			$charSet = self::DEFAULT_CHARACTER_SET;
		}

		$stmt = StringUtils::format(self::CREATE_DB_STMT, [
			'name' => $name,
			'charSet' => $charSet
		]);

		$this->db->exec($stmt);
	}