DbSearch-mysql.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines http://www.simplemachines.org
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.0
  11. */
  12. if (!defined('SMF'))
  13. die('Hacking attempt...');
  14. /* This file contains database functions specific to search related activity.
  15. void db_search_init()
  16. - adds the functions in this file to the $smcFunc array
  17. boolean smf_db_search_support($search_type)
  18. - whether this database type support the search type $search_type
  19. void smf_db_create_word_search($size)
  20. - create the custom word index table
  21. */
  22. // Add the file functions to the $smcFunc array.
  23. function db_search_init()
  24. {
  25. global $smcFunc;
  26. if (!isset($smcFunc['db_search_query']) || $smcFunc['db_search_query'] != 'smf_db_query')
  27. $smcFunc += array(
  28. 'db_search_query' => 'smf_db_query',
  29. 'db_search_support' => 'smf_db_search_support',
  30. 'db_create_word_search' => 'smf_db_create_word_search',
  31. 'db_support_ignore' => true,
  32. );
  33. }
  34. // Does this database type support this search type?
  35. function smf_db_search_support($search_type)
  36. {
  37. $supported_types = array('fulltext');
  38. return in_array($search_type, $supported_types);
  39. }
  40. // Highly specific - create the custom word index table!
  41. function smf_db_create_word_search($size)
  42. {
  43. global $smcFunc;
  44. if ($size == 'small')
  45. $size = 'smallint(5)';
  46. elseif ($size == 'medium')
  47. $size = 'mediumint(8)';
  48. else
  49. $size = 'int(10)';
  50. $smcFunc['db_query']('', '
  51. CREATE TABLE {db_prefix}log_search_words (
  52. id_word {raw:size} unsigned NOT NULL default {string:string_zero},
  53. id_msg int(10) unsigned NOT NULL default {string:string_zero},
  54. PRIMARY KEY (id_word, id_msg)
  55. ) ENGINE=InnoDB',
  56. array(
  57. 'string_zero' => '0',
  58. 'size' => $size,
  59. )
  60. );
  61. }
  62. ?>