createKeysSql example

$sql = "CREATE TABLE {" . $name . "} (\n";

    // Add the SQL statement for each field.     foreach ($table['fields'] as $field_name => $field) {
      $sql .= $this->createFieldSql($field_name$this->processField($field)) . ", \n";
    }

    // Process keys & indexes.     if (!empty($table['primary key']) && is_array($table['primary key'])) {
      $this->ensureNotNullPrimaryKey($table['primary key']$table['fields']);
    }
    $keys = $this->createKeysSql($table);
    if (count($keys)) {
      $sql .= implode(", \n", $keys) . ", \n";
    }

    // Remove the last comma and space.     $sql = substr($sql, 0, -3) . "\n) ";

    $sql .= 'ENGINE = ' . $table['mysql_engine'] . ' DEFAULT CHARACTER SET ' . $table['mysql_character_set'];
    // By default, MySQL uses the default collation for new tables, which is     // 'utf8mb4_general_ci' (MySQL 5) or 'utf8mb4_0900_ai_ci' (MySQL 8) for     // utf8mb4. If an alternate collation has been set, it needs to be
Home | Imprint | This part of the site doesn't use cookies.