function views_data_export_plugin_display_export::store_search_api_result in Views data export 7.3
Based on views_data_export_plugin_query_default_batched::execute().
1 call to views_data_export_plugin_display_export::store_search_api_result()
- views_data_export_plugin_display_export::initialize_index in plugins/
views_data_export_plugin_display_export.inc - Called on export initialization.
File
- plugins/
views_data_export_plugin_display_export.inc, line 869 - Contains the bulk export display plugin.
Class
- views_data_export_plugin_display_export
- The plugin that batches its rendering.
Code
function store_search_api_result($view) {
$display_handler =& $view->display_handler;
$start = microtime(TRUE);
try {
// Get all the view results.
$view->query
->set_limit(NULL);
$view->query
->set_offset(0);
$view->query
->execute($view);
$weight_alias = 'vde_weight';
$display_handler->batched_execution_state->sandbox['weight_field_alias'] = $weight_alias;
$schema = array(
'fields' => array(
$weight_alias => array(
'type' => 'int',
),
'data' => array(
'type' => 'blob',
),
),
);
db_create_table($display_handler
->index_tablename(), $schema);
if (!empty($view->result)) {
$insert_query = db_insert($display_handler
->index_tablename())
->fields(array(
$weight_alias,
'data',
));
$weight = 0;
foreach ($view->result as $item) {
$insert_query
->values(array(
$weight_alias => $weight,
'data' => serialize($item),
));
$weight++;
}
$insert_query
->execute();
}
$view->result = array();
// Now create an index for the weight field, otherwise the queries on the
// index will take a long time to execute.
db_add_unique_key($display_handler
->index_tablename(), $weight_alias, array(
$weight_alias,
));
} catch (Exception $e) {
$view->result = array();
debug('Exception: ' . $e
->getMessage());
}
$view->execute_time = microtime(TRUE) - $start;
}