You are here

function top_searches_update_6001 in Top Searches 6

File

./top_searches.install, line 55

Code

function top_searches_update_6001() {
  $ret = array();

  // Remove all non-valid search phrases from the DB (according to http://drupal.org/node/621842)
  $result = db_query('SELECT * FROM {top_searches}');
  while ($row = db_fetch_array($result)) {
    $valid = _top_searches_valid_phrase($row['q']);
    if (!$valid) {
      $ret[] = update_sql("DELETE FROM {top_searches} WHERE qid = {$row['qid']}");
      $removed[] = $row['q'];
    }
  }
  if (!empty($removed)) {
    drupal_set_message(t('The following non-valid phrases were removed from Top Searches table: %s', array(
      '%s' => implode(', ', $removed),
    )));
  }
  return $ret;
}