| Versionen | |
|---|---|
| drupal7 | public DatabaseSchema_sqlite::changeField(&$ret, $table, $field, $field_new, $spec, $keys_new = array()) |
Change a field definition.
This implementation can't use ALTER TABLE directly, because SQLite only supports a limited subset of that command.
$ret Array to which query results will be added.
$table Name of the table.
$field Name of the field to change.
$field_new New name for the field (set to the same as $field if you don't want to change the name).
$spec The field specification for the new field.
$keys_new Optional keys and indexes specification to be created on the table along with changing the field. The format is the same as a table specification but without the 'fields' element.
includes/
<?php
public function changeField(&$ret, $table, $field, $field_new, $spec, $keys_new = array()) {
$new_schema = $this->introspectSchema($table);
unset($new_schema['fields'][$field]);
$new_schema['fields'][$field_new] = $spec;
if (isset($keys_new['primary keys'])) {
$new_schema['primary keys'] = $keys_new['primary keys'];
$keys_new['primary keys'];
}
foreach (array('unique keys', 'indexes') as $k) {
if (!empty($keys_new[$k])) {
$new_schema[$k] = $keys_new[$k] + $new_schema[$k];
}
}
$this->alterTable($ret, $table, $new_schema);
}
?>
Kommentare
Kommentar hinzufügen