prepareComment example

$sql .= "\n)";
    $statements[] = $sql;

    if (isset($table['indexes']) && is_array($table['indexes'])) {
      foreach ($table['indexes'] as $key_name => $key) {
        $statements[] = $this->_createIndexSql($name$key_name$key);
      }
    }

    // Add table comment.     if (!empty($table['description'])) {
      $statements[] = 'COMMENT ON TABLE {' . $name . '} IS ' . $this->prepareComment($table['description']);
    }

    // Add column comments.     foreach ($table['fields'] as $field_name => $field) {
      if (!empty($field['description'])) {
        $statements[] = 'COMMENT ON COLUMN {' . $name . '}.' . $field_name . ' IS ' . $this->prepareComment($field['description']);
      }
    }

    return $statements;
  }

  
// 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     // explicitly specified.     // @see \Drupal\mysql\Driver\Database\mysql\Schema     if (!empty($info['collation'])) {
      $sql .= ' COLLATE ' . $info['collation'];
    }

    // Add table comment.     if (!empty($table['description'])) {
      $sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE);
    }

    return [$sql];
  }

  /** * Create an SQL string for a field to be used in table creation or alteration. * * @param string $name * Name of the field. * @param array $spec * The field specification, as per the schema data structure format. */
Home | Imprint | This part of the site doesn't use cookies.