[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/modules/poll/ -> poll.install (source)

   1  <?php
   2  
   3  /**
   4   * Implementation of hook_install().
   5   */
   6  function poll_install() {
   7    // Create tables.
   8    drupal_install_schema('poll');
   9  }
  10  
  11  /**
  12   * Implementation of hook_uninstall().
  13   */
  14  function poll_uninstall() {
  15    // Remove tables.
  16    drupal_uninstall_schema('poll');
  17  }
  18  
  19  /**
  20   * Implementation of hook_schema().
  21   */
  22  function poll_schema() {
  23    $schema['poll'] = array(
  24      'description' => 'Stores poll-specific information for poll nodes.',
  25      'fields' => array(
  26        'nid'     => array(
  27          'type' => 'int',
  28          'unsigned' => TRUE,
  29          'not null' => TRUE,
  30          'default' => 0,
  31          'description' => "The poll's {node}.nid."
  32          ),
  33        'runtime' => array(
  34          'type' => 'int',
  35          'not null' => TRUE,
  36          'default' => 0,
  37          'description' => 'The number of seconds past {node}.created during which the poll is open.'
  38          ),
  39        'active'  => array(
  40          'type' => 'int',
  41          'unsigned' => TRUE,
  42          'not null' => TRUE,
  43          'default' => 0,
  44          'description' => 'Boolean indicating whether or not the poll is open.',
  45          ),
  46        ),
  47      'primary key' => array('nid'),
  48      );
  49  
  50    $schema['poll_choices'] = array(
  51      'description' => 'Stores information about all choices for all {poll}s.',
  52      'fields' => array(
  53        'chid'    => array(
  54          'type' => 'serial',
  55          'unsigned' => TRUE,
  56          'not null' => TRUE,
  57          'description' => 'Unique identifier for a poll choice.',
  58          ),
  59        'nid'     => array(
  60          'type' => 'int',
  61          'unsigned' => TRUE,
  62          'not null' => TRUE,
  63          'default' => 0,
  64          'description' => 'The {node}.nid this choice belongs to.',
  65          ),
  66        'chtext'  => array(
  67          'type' => 'varchar',
  68          'length' => 128,
  69          'not null' => TRUE,
  70          'default' => '',
  71          'description' => 'The text for this choice.',
  72          ),
  73        'chvotes' => array(
  74          'type' => 'int',
  75          'not null' => TRUE,
  76          'default' => 0,
  77          'description' => 'The total number of votes this choice has received by all users.',
  78          ),
  79        'chorder' => array(
  80          'type' => 'int',
  81          'not null' => TRUE,
  82          'default' => 0,
  83          'description' => 'The sort order of this choice among all choices for the same node.',
  84          )
  85        ),
  86      'indexes' => array(
  87        'nid' => array('nid')
  88        ),
  89      'primary key' => array('chid'),
  90      );
  91  
  92    $schema['poll_votes'] = array(
  93      'description' => 'Stores per-{users} votes for each {poll}.',
  94      'fields' => array(
  95        'nid'      => array(
  96          'type' => 'int',
  97          'unsigned' => TRUE,
  98          'not null' => TRUE,
  99          'description' => 'The {poll} node this vote is for.',
 100          ),
 101        'uid'      => array(
 102          'type' => 'int',
 103          'unsigned' => TRUE,
 104          'not null' => TRUE,
 105          'default' => 0,
 106          'description' => 'The {users}.uid this vote is from unless the voter was anonymous.',
 107          ),
 108        'chorder'  => array(
 109          'type' => 'int',
 110          'not null' => TRUE,
 111          'default' => -1,
 112          'description' => "The {users}'s vote for this poll.",
 113          ),
 114        'hostname' => array(
 115          'type' => 'varchar',
 116          'length' => 128,
 117          'not null' => TRUE,
 118          'default' => '',
 119          'description' => 'The IP address this vote is from unless the voter was logged in.',
 120          ),
 121        ),
 122      'primary key' => array('nid', 'uid', 'hostname'),
 123      'indexes' => array(
 124        'hostname' => array('hostname'),
 125        'uid'      => array('uid'),
 126        ),
 127      );
 128  
 129    return $schema;
 130  }
 131  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7