function amazon_media_amazon_item_insert in Amazon Product Advertisement API 7
Same name and namespace in other branches
- 6 amazon_media/amazon_media.module \amazon_media_amazon_item_insert()
- 7.2 amazon_media/amazon_media.module \amazon_media_amazon_item_insert()
Insert the associated information into the related table.
Parameters
$item: Populated amazon item record.
File
- amazon_media/
amazon_media.module, line 137 - Provides additional behaviors and data type for amazon items which are DVDs, software, video games, music, etc.
Code
function amazon_media_amazon_item_insert($item) {
static $item_keys = NULL;
if (empty($item_keys)) {
require_once 'amazon_media.install';
$schema = amazon_media_schema();
$item_keys = $schema;
}
$table = amazon_media_get_table_name($item);
if (!empty($table)) {
// We need to present a record that only has the items in it used by
// this table.
$db_item = array_intersect_key($item, $item_keys[$table]['fields']);
try {
db_insert($table)
->fields($db_item)
->execute();
} catch (Exception $e) {
amazon_db_error_watchdog("Failed to insert item into amazon table", $e, $db_item);
}
}
}