function search_autocomplete_update_7420 in Search Autocomplete 7.4
Migrate no_results and all_results fields from 4.1 to 4.2 default values
File
- ./
search_autocomplete.install, line 451 - This file is used to install/update/delete the module tables in database
Code
function search_autocomplete_update_7420(&$sandbox) {
$all_fields = db_select('search_autocomplete_forms', 'sa')
->fields('sa', array(
'fid',
'no_results',
'all_results',
))
->execute()
->fetchAllAssoc('fid');
foreach ($all_fields as $fid => $field) {
// Remove html tags in no_results label
$no_results = json_decode($field->no_results);
$no_results->label = strip_tags($no_results->label);
$all_results = json_decode($field->all_results);
$all_results->label = strip_tags($all_results->label);
db_update('search_autocomplete_forms')
->fields(array(
'no_results' => json_encode($no_results),
'all_results' => json_encode($all_results),
))
->condition('fid', $fid, '=')
->execute();
}
}