+function insPrices($db,$pid,$prices) {
+ $rc = $db->query("BEGIN");
+ $sql="delete from prices where parts_id = ".$pid;
+ $rc = $db->query($sql);
+ $sql = "insert into prices (parts_id,pricegroup_id,price) values ((select id from parts where partnumber = '%s'),%d,%0.5f)";
+ foreach ($prices as $key => $val) {
+ $rc = $db->query(sprintf($sql,$pid,$key,$val));
+ if (!$rc) {
+ $db->query("ROLLBACK");
+ return false;
+ }
+ }
+ $db->query("COMMIT");
+ return true;
+}
+