You are here

function regcode_create_table in Registration codes 5.3

Helper function to create table for db storage

2 calls to regcode_create_table()
regcode_install in ./regcode.install
Implementation of hook_install().
regcode_update_5200 in ./regcode.install
Implementation of hook_update().

File

./regcode.install, line 44

Code

function regcode_create_table() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $result = db_query("\n        CREATE TABLE IF NOT EXISTS {regcode} (\n          `code` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,\n          `available` INT NOT NULL DEFAULT '1',\n          `reuse` INT NOT NULL DEFAULT '0',\n          `used_count` INT NOT NULL DEFAULT '0',\n          `uid` INT( 10 ) UNSIGNED NULL ,\n          `rid` INT( 10 ) UNSIGNED NULL ,\n          `created` INT( 11 ) NOT NULL DEFAULT '0',\n          `used`    INT( 11 ) NOT NULL DEFAULT '0',\n          `expire`  INT( 11 ) NOT NULL DEFAULT '0',\n          `revoke`  INT( 11 ) NOT NULL DEFAULT '0',\n          `info` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,\n          PRIMARY KEY ( `code` ),\n          INDEX ( `uid` ),\n          INDEX ( `rid` , `expire` )\n          )\n        ");
      watchdog('RegistrationCode', 'regcodes table created: ' . ($result['success'] ? 'successful' : 'FAILED'));
      break;
  }
  return $result;
}