class ExchangeRates
{
// have xml and json data
// this one goes with json, but it works same as xml
$i = 0;
foreach ($jsonData as $item) {
$unit = $item["Unit"];
$buyRateForeign = $item["buyRateForeign"];
$meanRate = $item["meanRate"];
$sellRateForeign = $item["sellRateForeign"];
$database = new Database();
$sql = "INSERT INTO currency_list (unit, source, buyRateForeign, meanRate, sellRateForeign) VALUES (:unit, :source, :buyRateForeign, :meanRate, :sellRateForeign)";
$stmt = $database->getConnection->prepare($sql);
$stmt->bindValue(':unit', $unti);
// etc...
$stmt->execute();
$i++;
}
}
If I use SELECT query, data will be returned as a string, so for a second I thought that be a reason for not working properly.