Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $operations = array();
- $items = array();
- $limit = 100;
- $i = 0;
- $regs = db_query("SELECT * FROM {table_import_apunte} WHERE field_processed = :processed", array(':processed' => 0));
- foreach ($regs as $row) {
- $row = (array) $row;
- if ($i < $limit) {
- $items[] = $row;
- $i += 1;
- } else {
- $operations[] = array('csvImporter_create_nodes', array($items, 'apunte'));
- $items = array();
- $items[] = $row;
- $i = 1;
- }
- }
- if (!empty($items)) {
- $operations[] = array('csvImporter_create_nodes', array($items, 'apunte'));
- $batch = array(
- 'title' => t('Importing %name table', array('%name' => drupal_strtoupper('apunte'))),
- 'init_message' => t('Starting Import...'),
- 'progress_message' => t('Processed @current out of @total.'),
- 'error_message' => t('There was a problem importing the file.'),
- 'operations' => $operations,
- 'finished' => 'csvImporter_batch_finished',
- );
- batch_set($batch);
- }
- while (($row = db_fetch_array($regs)) !== FALSE) {
- if ($i < $limit) {
- $items[] = $row;
- $i += 1;
- } else {
- $operations[] = array('_aicia_import_batch_create_nodes', array($items, $table));
- $items = array();
- $items[] = $row;
- $i = 1;
- }
- }
Add Comment
Please, Sign In to add comment