You are here

function search_api_saved_searches_update_7101 in Search API Saved Searches 7

Update searches to correctly use the settings' delta, not numeric ID, as the identifier.

File

./search_api_saved_searches.install, line 171
Install, update and uninstall functions for the Search API saved searches module.

Code

function search_api_saved_searches_update_7101() {
  $settings = db_query('SELECT id, delta FROM {search_api_saved_searches_settings}')
    ->fetchAllKeyed();
  db_delete('search_api_saved_search')
    ->condition('settings_id', array_keys($settings), 'NOT IN')
    ->execute();
  foreach ($settings as $id => $delta) {
    db_update('search_api_saved_search')
      ->condition('settings_id', $id)
      ->fields(array(
      'settings_id' => $delta,
    ))
      ->execute();
  }
}