2.0, ); } // A function to rewrite the SQL statement before submitting the query // Force GROUP BY feature_id and return only one row function tripal_search_unigene_views_pre_execute(&$view){ if ($view->name == 'unigene_search') { // AGGREGATORS $search = array('SELECT'); $replace = array('SELECT min('); $view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']); $view->build_info['count_query'] = str_replace($search, $replace, $view->build_info['count_query']); $search = array(','); $replace = array(', min('); $view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']); $view->build_info['count_query'] = str_replace($search, $replace, $view->build_info['count_query']); $search = array(' AS '); $replace = array(') AS '); $view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']); $view->build_info['count_query'] = str_replace($search, $replace, $view->build_info['count_query']); // GROUP BY if (preg_match("'ORDER BY'", $view->build_info['query'])) { $search = array('ORDER BY'); $replace = array('GROUP BY unigene_for_search.feature_id ORDER BY'); $view->build_info['query'] = str_replace($search, $replace, $view->build_info['query']); } else { $view->build_info['query'] .= " GROUP BY unigene_for_search.feature_id"; } $view->build_info['count_query'] .= " GROUP BY unigene_for_search.feature_id"; //drupal_set_message($view->build_info['query']); //drupal_set_message($view->build_info['count_query']); } }