tep_db_query_catalog("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
$sql_data_array = array('orders_id' => $insert_id,
'products_id' => tep_get_prid($order->products[$i]['id']),
'products_model' => $order->products[$i]['model'],
'products_name' => $order->products[$i]['name'],
'products_packaged_components' => $order->products[$i]['packaged_components'],
'products_price' => $order->products[$i]['price'],
'final_price' => $order->products[$i]['final_price'],
'products_tax' => $order->products[$i]['tax'],
'products_quantity' => $order->products[$i]['qty']);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = tep_db_insert_id();
The first query updates the bestsellers table. Note "tep_db_query_catalog" which is for the catalog database. Further down, the "tep_db_perform" is for the orders database. With the "tep_db_insert_id" being immediately following, it should be taking the auto_increment value for orders_products_id from the previous line... but it's not. It's writing zero which I'm assuming because it's perhaps using the connection to the catalog database. I've tried using tep_db_insert($$link) to specify the connection, but have the same result.
Anyone have any tips on how I can ensure it's using the right connection so I'll actually get the last auto_increment id value that was inserted in the tep_db_perform line?
Thanks!









