public function DataTable::changeIndex in Data 7
Same name and namespace in other branches
- 6 includes/DataTable.inc \DataTable::changeIndex()
Change indexes of a table.
Throws
File
- includes/
DataTable.inc, line 371 - Contains class definition for DataTable.
Class
- DataTable
- Manages data access and manipulation for a single data table. Use data_create_table() or data_get_table() to instantiate an object from this class.
Code
public function changeIndex($fields) {
$schema = $this->table_schema;
// @TODO: This array_keys() reduces indexes to single field indexes.
// Will need adjustment when multi-field indexes are implemented.
$indexes = isset($schema['indexes']) ? array_keys($schema['indexes']) : array();
$add = array_diff($fields, $indexes);
$drop = array_diff($indexes, $fields);
foreach ($add as $field) {
$this
->addIndex($field);
}
foreach ($drop as $field) {
$this
->dropIndex($field);
}
}