You are here

public function DataTable::changePrimaryKey in Data 6

Same name and namespace in other branches
  1. 7 includes/DataTable.inc \DataTable::changePrimaryKey()

Change the primary keys of a table.

Throws

DataException

File

includes/DataTable.inc, line 414
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 changePrimaryKey($fields) {
  $schema = $this->table_schema;
  if (!empty($schema['primary key'])) {
    $this
      ->dropPrimaryKey();
  }
  if (!empty($fields)) {
    $this
      ->addPrimaryKey($fields);
  }
}