You are here

protected static function FeedImport::insertItem in Feed Import 7.2

Same name and namespace in other branches
  1. 7 feed_import.inc.php \FeedImport::insertItem()

Insert imported item in feed_import_hashes

Parameters

mixed $values: An array of values or NULL to execute insert

1 call to FeedImport::insertItem()
FeedImport::saveEntities in ./feed_import.inc.php
Saves/updates all created entities

File

./feed_import.inc.php, line 875
Feed import class for parsing and processing content.

Class

FeedImport
@file Feed import class for parsing and processing content.

Code

protected static function insertItem($values) {
  static $q_insert = NULL;
  static $q_insert_items = 0;
  if ($q_insert == NULL) {
    $q_insert = db_insert('feed_import_hashes')
      ->fields(array(
      'feed_machine_name',
      'entity',
      'entity_id',
      'hash',
      'expire',
    ));
  }
  $q_insert_chunk = variable_get('feed_import_insert_hashes_chunk', 500);

  // Call execute and reset number of insert items.
  if ($values == NULL) {
    if ($q_insert_items) {
      $q_insert
        ->execute();
      $q_insert_items = 0;
    }
    return;
  }

  // Set values.
  $q_insert
    ->values($values);
  $q_insert_items++;
  if ($q_insert_items == $q_insert_chunk) {
    $q_insert
      ->execute();
    $q_insert_items = 0;
  }
}