qbf.install 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 2008-09-02 08:39:07 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. . ' PRIMARY KEY (`qid`) , '
  35. . ' INDEX (`uid`) '
  36. . ' ) '
  37. . 'ENGINE = MyISAM '
  38. . 'CHARACTER SET = utf8 '
  39. . "COMMENT = 'QBF Query store' ";
  40. db_query($sq);
  41. break;
  42. case pgsql:
  43. default:
  44. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  45. array('@db' => $GLOBALS['db_type'])), 'error');
  46. break;
  47. }
  48. }
  49. /**
  50. * Implement hook_uninstall().
  51. *
  52. * - Drop all the tables maintained by the module
  53. * - qbf_queries
  54. * - Remove nodes of all the types maintained by the module
  55. * - none
  56. * - Remove module settings
  57. * - none
  58. * - Do NOT remove module schema version from {system}
  59. *
  60. * @return void
  61. */
  62. function qbf_uninstall()
  63. {
  64. switch ($GLOBALS['db_type'])
  65. {
  66. case 'mysql':
  67. case 'mysqli':
  68. case 'pgsql':
  69. db_query("DROP TABLE {qbf_queries}");
  70. break;
  71. default:
  72. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  73. array('@db' => $GLOBALS['db_type'])), 'error');
  74. break;
  75. }
  76. }
  77. /**
  78. * Implement hook_update_N().
  79. *
  80. * For now, just define a proper initial schema version.
  81. *
  82. * @return array
  83. */
  84. function qbf_update_5000()
  85. {
  86. return array();
  87. }