node_example_install

5 node_example.install node_example_install()
6 node_example.install node_example_install()
7 node_example.install node_example_install()
8 node_example.install node_example_install()

Implementation of hook_install().

File

developer/examples/node_example.install, line 6

Code

function node_example_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("
          CREATE TABLE {node_example} (
            vid int(10) unsigned NOT NULL default '0',
            nid int(10) unsigned NOT NULL default '0',
            color varchar(255) NOT NULL default '',
            quantity int(10) unsigned NOT NULL default '0',
            PRIMARY KEY (vid, nid),
            KEY node_example_nid (nid)
          ) /*!40100 DEFAULT CHARACTER SET utf8 */;
      ");
      break;
    case 'pgsql':
      db_query("
          CREATE TABLE {node_example} (
            vid int NOT NULL default '0',
            nid int NOT NULL default '0',
            color varchar(255) NOT NULL default '',
            quantity int(10) unsigned NOT NULL default '0',
            PRIMARY KEY (vid, nid));
      ");
      db_query("CREATE INDEX {node_example}_nid_idx ON {node_example} (nid)");
      break;
  }
}
Login or register to post comments