From 867c8c94a1bed4bc862bc22f05922a5d9492b401 Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 9 Nov 2009 20:44:34 +0000 Subject: Updated search to allow filtering of results by clicking on submenu items. Fixes #1358: Using raw mysql_query() / fetch() to get ft_min/max vars since they aren't set on some versions of MySQL. git-svn-id: http://code.elgg.org/elgg/trunk@3645 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/search/start.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'mod/search/start.php') diff --git a/mod/search/start.php b/mod/search/start.php index cad2aab41..02f7da494 100644 --- a/mod/search/start.php +++ b/mod/search/start.php @@ -35,11 +35,19 @@ function search_init() { register_plugin_hook('search', 'comments', 'search_comments_hook'); // get server min and max allowed chars for ft searching - $word_lens = get_data('SELECT @@ft_min_word_len as min, @@ft_max_word_len as max'); - $CONFIG->search_info = array(); - $CONFIG->search_info['min_chars'] = $word_lens[0]->min; - $CONFIG->search_info['max_chars'] = $word_lens[0]->max; + + // can't use get_data() here because some servers don't have these globals set, + // which throws a db exception. + $r = mysql_query('SELECT @@ft_min_word_len as min, @@ft_max_word_len as max'); + if ($word_lens = mysql_fetch_assoc($r)) { + $CONFIG->search_info['min_chars'] = $word_lens['min']; + $CONFIG->search_info['max_chars'] = $word_lens['max']; + } else { + // uhhh these are good numbers. + $CONFIG->search_info['min_chars'] = 4; + $CONFIG->search_info['max_chars'] = 90; + } // add in CSS for search elements extend_view('css', 'search/css'); @@ -331,7 +339,7 @@ function search_get_where_sql($table, $fields, $params) { } $likes_str = implode(' OR ', $likes); //$where = "($table.guid = e.guid AND ($likes_str))"; - $where = "($likes_str))"; + $where = "($likes_str)"; } else { // if using advanced or paired "s, switch into boolean mode if ((isset($params['advanced_search']) && $params['advanced_search']) || substr_count($query, '"') >= 2 ) { -- cgit v1.2.3