function data_search_wipe in Data 8
Same name and namespace in other branches
- 6 data_search/data_search.module \data_search_wipe()
- 7 data_search/data_search.module \data_search_wipe()
Wipe all orphaned entries for given Data table. Use instead of search_wipe() if all items that have been deleted from table $table should be wiped. In this case, data_search_wipe() is faster than search_wipe().
Note: Like search_wipe(), this function does not reset the word counts in search_total.
Parameters
$table: DataTable object.
1 call to data_search_wipe()
- data_search_cron in data_search/
data_search.module - Implements hook_cron().
File
- data_search/
data_search.module, line 159
Code
function data_search_wipe($table) {
$connection = \Drupal::database();
$schema = $table
->get('table_schema');
$name = $connection
->escapeTable($table
->get('name'));
$field = db_escape_string(current($schema['primary key']));
// TODO Please convert this statement to the D7 database API syntax.
$connection
->query("DELETE s FROM {search_dataset} s LEFT JOIN {{$name}} t ON s.sid = t.{$field} WHERE s.type = '%s' AND t.{$field} IS NULL", $table
->get('name'));
// TODO Please convert this statement to the D7 database API syntax.
$connection
->query("DELETE s FROM {search_index} s LEFT JOIN {{$name}} t ON s.sid = t.{$field} WHERE s.type = '%s' AND t.{$field} IS NULL", $table
->get('name'));
}