You are here

function data_create_table in Data 7

Same name and namespace in other branches
  1. 8 data.module \data_create_table()
  2. 6 data.module \data_create_table()

Create a table.

Parameters

$name: String that identifies the data table. It is recommended to use data_name() to generate a table name in the data namespace. For example: $table = data_get_tabe(data_name('my_table'));

$schema: Schema for the table.

$title: A natural title for the table.

Return value

A DataTable object if one could be created, FALSE otherwise.

See also

DataTable class.

3 calls to data_create_table()
DataTestCaseAPI::testAPIFunctions in tests/data.test
Test API functions of DataTable and DataHandler.
DataTestCaseAPI::testCRUD in tests/data.test
Run CRUD tests.
data_ui_create_form_submit in data_ui/data_ui.admin.inc
Submit handler for create table form.

File

./data.module, line 49
Hooks and API functions for data module.

Code

function data_create_table($name, $schema, $title = NULL) {
  $table = DataTable::instance($name);
  if ($table
    ->create($schema)) {
    if (!empty($title)) {
      $table
        ->update(array(
        'title' => $title,
      ));
    }
    return $table;
  }
  return FALSE;
}