I have several entries in XML file with "special number".
I have to search the database for these values.
If the number was not found in the database, then this "special number" and associated data should be stored in the database.
<?php
foreach($array_from_xml_file as $key => $value) {
if($key === 'special_nummer'){
$sql = $db->loadArray("SELECT email FROM table WHERE special_nummer = $value");
// If nothing found insert new Data.
if(empty($sql)){
$insert_data = $db->insertData("INSERT INTO table (special_nummer, title, content) VALUES ('$key','$value','....')");
}
}
}
?>
Disadvantage of this founction places a heavy load on the database.
My second method
I load the whole column with "special numbers" from database into an XML file or array.
Find the numbers that are not in the database and create a new array. Save this array to database.
My question: How do I make it most efficient?