Se vuoi sapere se la tabella è stata importata oppure aggiornata, esegui prima questo script:
SELECT COUNT(*) AS countOfDetails FROM details
Poi, in PHP:
$messageString = ""; // assign the countOfDetails from the Query to a PHP variable $myCount if($myCount==0){ $messageString = "Database Imported Successfully!"; } else{ $messageString = "Database Updated Successfully!"; }
Infine puoi eseguire lo script che importa o aggiorna la tabella:
INSERT INTO details (name, download) SELECT item_name, items_download FROM Source WHERE NOT EXISTS ( SELECT name, download FROM details WHERE name IN ( SELECT item_name FROM Source ) )
Dopo l'esecuzione, mostra la variabile $messageString dove preferisci.
NOTA: questa query inserisce solo le righe non già presenti nella tabella details, quindi non genererà mai errori di duplicazione.