I have a MySQL table called season
I'm getting data from a PostgreSQL then store it inside my array and then i use the implode function to pass the data stored inside the array:
$season = array(
'asset_id' => $asset_id,
'number' => $season_number
);
$season_col = implode(', ', array_keys($season));
$season_values = implode(', ', array_values($season));
Then I insert:
$insert_season = mysqli_query($conn, "INSERT INTO season(".$season_col.") VALUES(".$season_values.")");
This is one of 6 tables where i'm inserting data, and the problem is that when I run the code it does not insert all the data at once, I have to reload the page several times before it's all inserted. I also must add that the tables are all Interconnected with foreign keys, and also i tried disable the foreign key check and it did nothing for me.
I also do a check in php for repeated and nonexistent data:
$check_for_season = mysqli_query($conn, "SELECT asset_id, number FROM season WHERE asset_id = ".$asset_id." AND number = ".$season_number." LIMIT 1");
if (mysqli_fetch_array($check_for_season)) {
echo "Updates data";
} else {
$insert_season = mysqli_query($conn, "INSERT INTO season(".$season_col.") VALUES(".$season_values.")");
}
}