You are here

function _asin_migrate_from_d5 in Amazon Product Advertisement API 6

1 call to _asin_migrate_from_d5()
_asin_migrate_field_from_d5 in asin/asin.d5-migrate.inc
Batch Operation Callback

File

asin/asin.d5-migrate.inc, line 59

Code

function _asin_migrate_from_d5($nid, $fields) {
  $results = db_query("SELECT asin, ntype FROM {amazonnode} an WHERE an.nid = %d", $nid);
  $dirty = FALSE;
  $node = node_load($nid);
  while ($asin = db_fetch_object($results)) {
    if (array_key_exists($asin->ntype, $fields)) {
      $node->{$asin->ntype}[]['asin'] = $asin->asin;
    }
  }
  node_save($node);
  $sql = "DELETE FROM {amazonnode} WHERE nid = %d AND ntype IN (" . db_placeholders($fields, 'varchar') . ")";
  $params = array_keys($fields);
  array_unshift($params, $nid);
  db_query($sql, $params);
  return $node;
}