function tabledrag_example_schema

Same name in other branches
  1. 3.x modules/tabledrag_example/tabledrag_example.install \tabledrag_example_schema()
  2. 8.x-1.x tabledrag_example/tabledrag_example.install \tabledrag_example_schema()
  3. 4.0.x modules/tabledrag_example/tabledrag_example.install \tabledrag_example_schema()

Implements hook_schema().

This defines the database table which will hold the example item info.

Related topics

File

tabledrag_example/tabledrag_example.install, line 17

Code

function tabledrag_example_schema() {
    $schema['tabledrag_example'] = array(
        'description' => 'Stores some entries for our tabledrag fun.',
        'fields' => array(
            'id' => array(
                'description' => 'The primary identifier for each item',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ),
            'name' => array(
                'description' => 'A name for this item',
                'type' => 'varchar',
                'length' => 32,
                'not null' => TRUE,
                'default' => '',
            ),
            'description' => array(
                'description' => 'A description for this item',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ),
            'itemgroup' => array(
                'description' => 'The group this item belongs to',
                'type' => 'varchar',
                'length' => 32,
                'not null' => TRUE,
                'default' => '',
            ),
            'weight' => array(
                'description' => 'The sortable weight for this item',
                'type' => 'int',
                'length' => 11,
                'not null' => TRUE,
                'default' => 0,
            ),
            'pid' => array(
                'description' => 'The primary id of the parent for this item',
                'type' => 'int',
                'length' => 11,
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ),
            'depth' => array(
                'description' => 'The depth of this item within the tree',
                'type' => 'int',
                'size' => 'small',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'primary key' => array(
            'id',
        ),
    );
    return $schema;
}