1
Hello, gentlemen
I am working on a project for a hobby I have and am having a hard time with the MYSQL part. I have an array that comes from the API and is decoded and inserts some data of the connections in DB. So far, everything normal. However, the connections will be closed later - after all customers will disconnect from the network. I need these records to be deleted from DB, and so I thought I’d use Mysql’s NOT IN. Searching the internet, I realized that I would have to use the php implode to be able to adapt to the 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 - the $i comes from a loop that fetches the API data. The problem is that when executing the code it simply deletes all records, including those that still have Callsign in the array.
How do I proceed in this situation? I have researched several places, including here in Stackoverflow itself and found no reference.
From now on, I thank you and would like to inform and I apologize for any bizarre code. I am beginner in language. For those who want to see some more of the code, it’s uploaded to Github by the url: github.com/Sirgwaihir/parsec
Hug
Try $comma_separated = implode("','", $csv[$i]);
– Bacco