You are here

function search_autocomplete_update_6402 in Search Autocomplete 6.4

Change columns from TEXT to LONGTEXT and add filters in callbacks.

File

./search_autocomplete.install, line 260
This file is used to install/update/delete the module tables in database

Code

function search_autocomplete_update_6402(&$sandbox) {
  $ret = array();

  // Create the definition for the field.
  $new_field = array(
    'description' => 'Static text as a data',
    'type' => 'text',
    'size' => 'big',
  );
  db_change_field($ret, 'search_autocomplete_forms', 'data_static', 'data_static', $new_field);

  // Select data_callbacks of.
  $result = db_select('search_autocomplete_forms', 'f')
    ->fields('f', array(
    'fid',
    'data_callback',
  ))
    ->execute()
    ->fetchAll();
  foreach ($result as $item) {
    db_update('search_autocomplete_forms')
      ->fields(array(
      'data_callback' => $item->data_callback . '?filter=',
    ))
      ->condition('data_callback', array(
      'autocomplete-nodes',
      'autocomplete-users',
    ), 'IN')
      ->execute();
  }
  return t('Update has:') . '<br/>' . t('- changed column type "data_static" from TEXT to LONGTEXT.') . '<br/>' . t('- Add filter to VIEWS callback for performance improvement.');
}