- $sql = "SELECT parent, component, quantity FROM ".TB_PREF."bom WHERE parent = '$stock_id'";
- $result = db_query($sql, "Could not search bom");
- $bom = array();
- while ($row = db_fetch_row($result)) {
- $bom[] = array($row[0], $row[1], $row[2]);
- }
- db_free_result($result);
+ $bom = $bom_list[$stock_id];
+ if ($bom == NULL) {
+ $sql = "SELECT parent, component, quantity FROM ".TB_PREF."bom WHERE parent = '$stock_id'";
+ $result = db_query($sql, "Could not search bom");
+ $bom = array();
+ // Even if we get no results, remember that fact
+ $bom[] = array($stock_id, '', 0);
+ while ($row = db_fetch_row($result)) {
+ $bom[] = array($row[0], $row[1], $row[2]);
+ }
+ db_free_result($result);
+ $bom_list[$stock_id] = $bom;
+ }