protected function FeedsNodeProcessor::existingItemId in Feeds 6
Same name and namespace in other branches
- 7 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::existingItemId()
Get nid of an existing feed item node if available.
Overrides FeedsProcessor::existingItemId
1 call to FeedsNodeProcessor::existingItemId()
- FeedsNodeProcessor::process in plugins/
FeedsNodeProcessor.inc - Implementation of FeedsProcessor::process().
File
- plugins/
FeedsNodeProcessor.inc, line 360 - Class definition of FeedsNodeProcessor.
Class
- FeedsNodeProcessor
- Creates nodes from feed items.
Code
protected function existingItemId(FeedsImportBatch $batch, FeedsSource $source) {
// Iterate through all unique targets and test whether they do already
// exist in the database.
foreach ($this
->uniqueTargets($batch) as $target => $value) {
switch ($target) {
case 'nid':
$nid = db_result(db_query("SELECT nid FROM {node} WHERE nid = %d", $value));
break;
case 'url':
$nid = db_result(db_query("SELECT nid FROM {feeds_node_item} WHERE feed_nid = %d AND id = '%s' AND url = '%s'", $source->feed_nid, $source->id, $value));
break;
case 'guid':
$nid = db_result(db_query("SELECT nid FROM {feeds_node_item} WHERE feed_nid = %d AND id = '%s' AND guid = '%s'", $source->feed_nid, $source->id, $value));
break;
}
if ($nid) {
// Return with the first nid found.
return $nid;
}
}
return 0;
}