qbf.install 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.3 2008-10-03 13:47:41 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. * @ingroup hooks
  23. * @return void
  24. */
  25. function qbf_install() {
  26. switch ($GLOBALS['db_type'])
  27. {
  28. case 'mysql':
  29. case 'mysqli':
  30. $sq = 'CREATE TABLE {qbf_queries} '
  31. . ' ( '
  32. . " `qid` INT(10) NOT NULL DEFAULT '0' COMMENT 'Query ID', "
  33. . " `uid` INT(10) NOT NULL DEFAULT '0' COMMENT 'User ID', "
  34. . " `name` VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'Query name', "
  35. . " `query` TEXT NOT NULL COMMENT 'Query array', "
  36. . " `created` INT(10) NOT NULL DEFAULT '0' COMMENT 'Creation timestamp', "
  37. . " `updated` INT(10) NOT NULL DEFAULT '0' COMMENT 'Update timestamp', "
  38. . ' PRIMARY KEY (`qid`) , '
  39. . ' KEY `uid` (`uid`), '
  40. . ' KEY `updated`(`updated`) '
  41. . ' ) '
  42. . 'ENGINE = MyISAM '
  43. . 'CHARACTER SET = utf8 '
  44. . "COMMENT = 'QBF Query store' ";
  45. db_query($sq);
  46. break;
  47. case pgsql:
  48. default:
  49. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  50. array('@db' => $GLOBALS['db_type'])), 'error');
  51. break;
  52. }
  53. }
  54. /**
  55. * Implement hook_uninstall().
  56. *
  57. * - Drop all the tables maintained by the module
  58. * - qbf_queries
  59. * - Remove nodes of all the types maintained by the module
  60. * - none
  61. * - Remove module settings
  62. * - none
  63. * - Do NOT remove module schema version from {system}
  64. *
  65. * @ingroup hooks
  66. * @return void
  67. */
  68. function qbf_uninstall() {
  69. switch ($GLOBALS['db_type'])
  70. {
  71. case 'mysql':
  72. case 'mysqli':
  73. case 'pgsql':
  74. db_query("DROP TABLE {qbf_queries}");
  75. break;
  76. default:
  77. drupal_set_message(t('Unsupported database backend for QBF module: @db',
  78. array('@db' => $GLOBALS['db_type'])), 'error');
  79. break;
  80. }
  81. }
  82. /**
  83. * Implement hook_update_N().
  84. *
  85. * For now, just define a proper initial schema version.
  86. *
  87. * @ingroup hooks
  88. * @return array
  89. */
  90. function qbf_update_5000() {
  91. return array();
  92. }