Create table by using hook_schema


/**
 * Implements hook_schema().
 */
function MYMODULE_schema() {
  $schema['MYTABLE'] = array(
    'description' => 'DESCRIPTION',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 4,
        'not null' => TRUE,
      ),
      'created' => array(
        'description' => 'Unix timestamp.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'changed' => array(
        'description' => 'Unix timestamp.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'banner_changed' => array('changed'),
      'banner_created' => array('created'),
      'language' => array('language'),
    ),
    'unique keys' => array(
    ),
    'primary key' => array('id'),
  );
  return $schema;
}

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.