qbf.install 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * QBF module - installer
  4. *
  5. * @copyright 2008 Ouest Systèmes Informatiques SARL
  6. * @author FG Marand
  7. * @license GPL2 or later
  8. * @package QBF
  9. */
  10. // $Id: qbf.install,v 1.1.2.1 2008-09-21 09:35:33 marand Exp $
  11. /**
  12. * Implement hook_install().
  13. *
  14. * - Create the QBF tables
  15. * - qbf_queries
  16. * - Assign initial settings
  17. * - none
  18. *
  19. * @todo support PGSQL
  20. * @return void
  21. */
  22. function qbf_install()
  23. {
  24. switch ($GLOBALS['db_type'])
  25. {
  26. case 'mysql':
  27. case 'mysqli':
  28. $sq = 'CREATE TABLE {qbf_queries} '
  29. . ' ( '
  30. . " `qid` INT(10) NOT NULL DEFAULT '0' COMMENT 'Query ID', "
  31. . " `uid` INT(10) NOT NULL DEFAULT '0' COMMENT 'User ID', "
  32. . " `name` VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'Query name', "
  33. . " `query` TEXT NOT NULL COMMENT 'Query array', "
  34. . " `created` INT(10) NOT NULL DEFAULT '0' COMMENT 'Creation timestamp', "
  35. . " `updated` INT(10) NOT NULL DEFAULT '0' COMMENT 'Update timestamp', "
  36. . ' PRIMARY KEY (`qid`) , '
  37. . ' KEY `uid` (`uid`), '
  38. . ' KEY `updated`(`updated`) '
  39. . ' ) '
  40. . 'ENGINE = MyISAM '
  41. . 'CHARACTER SET = utf8 '
  42. . "COMMENT = 'QBF Query store' ";
  43. db_query($sq);
  44. break;
  45. case pgsql:
  46. default:
  47. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  48. array('@db' => $GLOBALS['db_type'])), 'error');
  49. break;
  50. }
  51. }
  52. /**
  53. * Implement hook_uninstall().
  54. *
  55. * - Drop all the tables maintained by the module
  56. * - qbf_queries
  57. * - Remove nodes of all the types maintained by the module
  58. * - none
  59. * - Remove module settings
  60. * - none
  61. * - Do NOT remove module schema version from {system}
  62. *
  63. * @return void
  64. */
  65. function qbf_uninstall()
  66. {
  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. {
  89. return array();
  90. }