function amazon_item_lookup_from_db in Amazon Product Advertisement API 6
Same name and namespace in other branches
- 7.2 amazon.module \amazon_item_lookup_from_db()
- 7 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 397
Code
function amazon_item_lookup_from_db($item_ids = array()) {
if (!empty($item_ids)) {
$sql = "SELECT * FROM {amazon_item} ai WHERE ai.asin IN (";
$sql .= implode(',', array_fill(0, count($item_ids), "'%s'")) . ') ';
$sql .= 'AND ai.timestamp > %d';
$results = db_query($sql, array_merge($item_ids, array(
time() - variable_get('amazon_refresh_schedule', 86400),
)));
$items = array();
while ($item = db_fetch_array($results)) {
_amazon_load_child_data($item);
$item += module_invoke_all('amazon_item_load', $item);
$items["{$item['asin']}"] = $item;
}
return $items;
}
return array();
}