qbf.install 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * QBF module - installer
  5. *
  6. * Copyright 2008 Ouest Systèmes Informatiques SARL
  7. *
  8. * Author FG Marand
  9. *
  10. * License GPL2 or later
  11. */
  12. // $Id: qbf.install,v 1.1.2.2 2008-09-21 10:20:04 marand Exp $
  13. /**
  14. * Implement hook_install().
  15. *
  16. * - Create the QBF tables
  17. * - qbf_queries
  18. * - Assign initial settings
  19. * - none
  20. *
  21. * @todo support PGSQL
  22. * @return void
  23. */
  24. function qbf_install() {
  25. switch ($GLOBALS['db_type'])
  26. {
  27. case 'mysql':
  28. case 'mysqli':
  29. $sq = 'CREATE TABLE {qbf_queries} '
  30. . ' ( '
  31. . " `qid` INT(10) NOT NULL DEFAULT '0' COMMENT 'Query ID', "
  32. . " `uid` INT(10) NOT NULL DEFAULT '0' COMMENT 'User ID', "
  33. . " `name` VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'Query name', "
  34. . " `query` TEXT NOT NULL COMMENT 'Query array', "
  35. . " `created` INT(10) NOT NULL DEFAULT '0' COMMENT 'Creation timestamp', "
  36. . " `updated` INT(10) NOT NULL DEFAULT '0' COMMENT 'Update timestamp', "
  37. . ' PRIMARY KEY (`qid`) , '
  38. . ' KEY `uid` (`uid`), '
  39. . ' KEY `updated`(`updated`) '
  40. . ' ) '
  41. . 'ENGINE = MyISAM '
  42. . 'CHARACTER SET = utf8 '
  43. . "COMMENT = 'QBF Query store' ";
  44. db_query($sq);
  45. break;
  46. case pgsql:
  47. default:
  48. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  49. array('@db' => $GLOBALS['db_type'])), 'error');
  50. break;
  51. }
  52. }
  53. /**
  54. * Implement hook_uninstall().
  55. *
  56. * - Drop all the tables maintained by the module
  57. * - qbf_queries
  58. * - Remove nodes of all the types maintained by the module
  59. * - none
  60. * - Remove module settings
  61. * - none
  62. * - Do NOT remove module schema version from {system}
  63. *
  64. * @return void
  65. */
  66. function qbf_uninstall() {
  67. switch ($GLOBALS['db_type'])
  68. {
  69. case 'mysql':
  70. case 'mysqli':
  71. case 'pgsql':
  72. db_query("DROP TABLE {qbf_queries}");
  73. break;
  74. default:
  75. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  76. array('@db' => $GLOBALS['db_type'])), 'error');
  77. break;
  78. }
  79. }
  80. /**
  81. * Implement hook_update_N().
  82. *
  83. * For now, just define a proper initial schema version.
  84. *
  85. * @return array
  86. */
  87. function qbf_update_5000() {
  88. return array();
  89. }