Hello, gentlemen
I'm working on a project for a hobby that I have and I'm having a hard time with the MYSQL part. I have an array that comes from the API and is decoded and inserts some data from the connections in the DB. So far, everything normal. However, the connections will be closed later - after all, clients will disconnect from the network. I need these records to be deleted from the DB, and then I thought about using MySQL's NOT IN. Searching the internet, I realized that I would have to use the php implode to be able to fit MYSQL format. So I created:
$comma_separated = "'" implode("", $csv[$i]) "'" ;
//Comando SQL - Remove do DB aeronaves que não partem do Brasil
$sql = "DELETE FROM connections WHERE callsign not in ('$comma_separated')";
Where, csv is the array with the data - $ i comes from a loop that fetches the API data. The problem is that by executing the code it simply deletes all records, including those that still have the callsign in the array.
How do I proceed in this situation? I have already researched in several places, including here in StackOverflow itself and found no reference.
From now on, thank you and would like to inform and apologize for any bizarre code. I am a beginner in language. For those who want to see some more of the code, it's up in GitHub by url: github.com/SirGwaihir/parsec
Embrace