node_example.install

  1. examples
    1. 6 node_example/node_example.install
    2. 7 node_example/node_example.install
    3. 8 node_example/node_example.install
  2. drupal
    1. 5 developer/examples/node_example.install

Functions & methods

NameDescription
node_example_installImplementation of hook_install().
node_example_uninstallImplementation of hook_uninstall().

File

developer/examples/node_example.install
View source
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function node_example_install() {
  6. switch ($GLOBALS['db_type']) {
  7. case 'mysql':
  8. case 'mysqli':
  9. db_query("
  10. CREATE TABLE {node_example} (
  11. vid int(10) unsigned NOT NULL default '0',
  12. nid int(10) unsigned NOT NULL default '0',
  13. color varchar(255) NOT NULL default '',
  14. quantity int(10) unsigned NOT NULL default '0',
  15. PRIMARY KEY (vid, nid),
  16. KEY node_example_nid (nid)
  17. ) /*!40100 DEFAULT CHARACTER SET utf8 */;
  18. ");
  19. break;
  20. case 'pgsql':
  21. db_query("
  22. CREATE TABLE {node_example} (
  23. vid int NOT NULL default '0',
  24. nid int NOT NULL default '0',
  25. color varchar(255) NOT NULL default '',
  26. quantity int(10) unsigned NOT NULL default '0',
  27. PRIMARY KEY (vid, nid));
  28. ");
  29. db_query("CREATE INDEX {node_example}_nid_idx ON {node_example} (nid)");
  30. break;
  31. }
  32. }
  33. /**
  34. * Implementation of hook_uninstall().
  35. */
  36. function node_example_uninstall() {
  37. if (db_table_exists('node_example')) {
  38. db_query("DROP TABLE {node_example}");
  39. }
  40. }
Login or register to post comments