diff -r e6e5d007eb54 -r c0f0bbfefd63 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Mon Dec 17 22:24:32 2018 +0100 +++ b/www/import/from_brouwhulp.php Wed Dec 19 21:58:21 2018 +0100 @@ -722,35 +722,31 @@ function recipe_waters($recipe, $db) { - $waters = "["; - $comma = FALSE; + $waters = ""; + $index = 0; foreach ($recipe->WATERS->WATER as $water) { - if ($comma) - $waters .= ','; - $comma = TRUE; - $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; - $waters .= ',"w_amount":' . floatval($water->AMOUNT); + $index++; + $waters .= "', w" . $index . "_name='" . mysqli_real_escape_string($db, $water->NAME); + $waters .= "', w" . $index . "_amount='" . floatval($water->AMOUNT); if ($water->CALCIUM) - $waters .= ',"w_calcium":' . floatval($water->CALCIUM); + $waters .= "', w" . $index . "_calcium='" . floatval($water->CALCIUM); if ($water->SULFATE) - $waters .= ',"w_sulfate":' . floatval($water->SULFATE); + $waters .= "', w" . $index . "_sulfate='" . floatval($water->SULFATE); if ($water->CHLORIDE) - $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); + $waters .= "', w" . $index . "_chloride='" . floatval($water->CHLORIDE); if ($water->SODIUM) - $waters .= ',"w_sodium":' . floatval($water->SODIUM); + $waters .= "', w" . $index . "_sodium='" . floatval($water->SODIUM); if ($water->MAGNESIUM) - $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); + $waters .= "', w" . $index . "_magnesium='" . floatval($water->MAGNESIUM); if ($water->PH) - $waters .= ',"w_ph":' . floatval($water->PH); + $waters .= "', w" . $index . "_ph='" . floatval($water->PH); if ($water->TOTAL_ALKALINITY) - $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); + $waters .= "', w" . $index . "_total_alkalinity='" . floatval($water->TOTAL_ALKALINITY); if ($water->COST) - $waters .= ',"w_cost":' . floatval($water->COST); + $waters .= "', w" . $index . "_cost='" . floatval($water->COST); else - $waters .= ',"w_cost":0.00'; - $waters .= "}"; + $waters .= "', w" . $index . "_cost='0"; } - $waters .= ']'; return $waters; } @@ -792,7 +788,6 @@ $len_hops = 0; $len_miscs = 0; $len_yeasts = 0; - $len_waters = 0; $len_mash = 0; echo " Start adding recipes to the database\n"; @@ -913,13 +908,10 @@ } /* - * Put the waters in a json array + * Get the waters */ if ($recipe->WATERS) { - $waters = recipe_waters($recipe, $db); - $sql .= "', json_waters='" . $waters; - if (strlen($waters) > $len_waters) - $len_waters = strlen($waters); + $sql .= recipe_waters($recipe, $db); } /* @@ -960,7 +952,6 @@ // echo "Hops: " . $len_hops . PHP_EOL; // echo "Miscs: " . $len_miscs . PHP_EOL; // echo "Yeasts: " . $len_yeasts . PHP_EOL; -// echo "Waters: " . $len_waters . PHP_EOL; // echo "Mash: " . $len_mash . PHP_EOL; } @@ -973,7 +964,6 @@ $len_hops = 0; $len_miscs = 0; $len_yeasts = 0; - $len_waters = 0; $len_mash = 0; echo " Start adding brews to the database\n"; @@ -1107,13 +1097,10 @@ } /* - * Put the waters in a json array + * Get the waters */ if ($recipe->WATERS) { - $waters = recipe_waters($recipe, $db); - $rsql .= "', json_waters='" . $waters; - if (strlen($waters) > $len_waters) - $len_waters = strlen($waters); + $rsql .= recipe_waters($recipe, $db); } /*