function amazon_item_lookup_from_db in Amazon Product Advertisement API 7
Same name and namespace in other branches
- 6 amazon.module \amazon_item_lookup_from_db()
- 7.2 amazon.module \amazon_item_lookup_from_db()
Look up ASINs in database and return arrays of information keyed by ASIN.
Parameters
$item_ids: An array of string ASINs.
Return value
array Array of Amazon 'cleaned' data structures keyed by ASIN.
1 call to amazon_item_lookup_from_db()
- amazon_item_lookup in ./
amazon.module - Look up an item using database or web. The default is to look in the database for existing data, and then to do the web search if that fails. $force_lookup==TRUE forces going to Amazon's API.
File
- ./
amazon.module, line 460
Code
function amazon_item_lookup_from_db($item_ids = array()) {
if (!empty($item_ids)) {
$timestamp = REQUEST_TIME - variable_get('amazon_refresh_schedule', 86400);
$result = db_query('SELECT * from {amazon_item} WHERE asin IN (:asins) AND timestamp > :timestamp', array(
':asins' => $item_ids,
':timestamp' => $timestamp,
), array(
'fetch' => PDO::FETCH_ASSOC,
));
$items = array();
foreach ($result as $item) {
_amazon_load_child_data($item);
$item += module_invoke_all('amazon_item_load', $item);
$items["{$item['asin']}"] = $item;
}
return $items;
}
return array();
}