You are here

function advpoll_install in Advanced Poll 5

Same name and namespace in other branches
  1. 8 advpoll.install \advpoll_install()
  2. 6.3 advpoll.install \advpoll_install()
  3. 6 advpoll.install \advpoll_install()
  4. 6.2 advpoll.install \advpoll_install()
  5. 7.3 advpoll.install \advpoll_install()
  6. 7 advpoll.install \advpoll_install()
  7. 7.2 advpoll.install \advpoll_install()

Implementation of hook_install().

File

./advpoll.install, line 6

Code

function advpoll_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {advpoll} (\n        nid int NOT NULL,\n        quorum int NOT NULL default '0',\n        mode varchar(32) NOT NULL,\n        use_list tinyint default '0',\n        active tinyint default '1',\n        max_choices int unsigned NOT NULL default '0',\n        algorithm VARCHAR(100),\n        show_votes tinyint NOT NULL default '1',\n        start_date int NOT NULL default '0',\n        end_date int NOT NULL default '0',\n        writeins tinyint NOT NULL default '0',\n        show_writeins tinyint NOT NULL default '0',\n        question varchar(255) NOT NULL default '',\n        PRIMARY KEY (nid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {advpoll_electoral_list} (\n        nid int(10) NOT NULL,\n        uid int(10) NOT NULL,\n        PRIMARY KEY (nid, uid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      db_query("CREATE TABLE {advpoll_choices} (\n        cid int unsigned NOT NULL auto_increment,\n        nid int(10) NOT NULL,\n        label text NOT NULL,\n        weight int unsigned NOT NULL,\n        writein tinyint NOT NULL default '0',\n        PRIMARY KEY (cid),\n        KEY nid_(nid, weight)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {advpoll} (\n        nid integer NOT NULL,\n        quorum integer NOT NULL default '0',\n        mode varchar(32) NOT NULL,\n        use_list smallint default '0',\n        active smallint default '1',\n        max_choices integer NOT NULL default '0',\n        algorithm varchar(100),\n        show_votes smallint NOT NULL default '1',\n        start_date integer NOT NULL default '0',\n        end_date integer NOT NULL default '0',\n        writeins smallint NOT NULL default '0',\n        show_writeins smallint NOT NULL default '0',\n        question varchar(255) NOT NULL default '',\n        PRIMARY KEY (nid)\n      )");
      db_query("CREATE TABLE {advpoll_electoral_list} ( \n        nid integer NOT NULL,\n        uid integer NOT NULL,\n        PRIMARY KEY (nid, uid)   \n      )");
      db_query("CREATE TABLE {advpoll_choices} (\n        cid serial,\n        nid integer NOT NULL,\n        label text NOT NULL,\n        weight smallint NOT NULL,\n        writein smallint NOT NULL default '0',\n        PRIMARY KEY (cid)\n      )");
      db_query('CREATE INDEX {advpoll_choices}_nid_weight_idx ON {advpoll_choices} (nid, weight)');
      break;
  }
}