protected function FeedsNodeProcessor::existingItemId in Feeds 7
Same name and namespace in other branches
- 6 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 - Implements FeedsProcessor::process().
File
- plugins/
FeedsNodeProcessor.inc, line 305 - 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_query("SELECT nid FROM {node} WHERE nid = :nid", array(
':nid' => $value,
))
->fetchField();
break;
case 'url':
$nid = db_query("SELECT nid FROM {feeds_node_item} WHERE feed_nid = :nid AND id = :id AND url = :url", array(
':nid' => $source->feed_nid,
':id' => $source->id,
':url' => $value,
))
->fetchField();
break;
case 'guid':
$nid = db_query("SELECT nid FROM {feeds_node_item} WHERE feed_nid = :nid AND id = :id AND guid = :guid", array(
':nid' => $source->feed_nid,
':id' => $source->id,
':guid' => $value,
))
->fetchField();
break;
}
if ($nid) {
// Return with the first nid found.
return $nid;
}
}
return 0;
}