My plan is to update/insert existing/new records into a database from an external, i have the information set to go into the database, but cannot check if it exists already.
my first attempted at doing database stuff
$link = resdb::connect();
$q = "IF ( EXISTS ( SELECT * FROM property AS this WHERE this.name = $propertyname ) )"
."begin"
// UPDATE PROPERTY IF IT EXISTS
."UPDATE property (name, propertylocation, propertyrating, propertytype)"
."SET ($propertyname, $locationid, $ratingid, $typeid)"
."WHERE name = $propertyname"
."end"
."ELSE"
."begin"
."INSERT INTO property (name, propertylocation, propertyrating, propertytype)"
."VALUES ($propertyname, $locationid, $ratingid, $typeid)"
."end";
$r = mysqli_query($link, $q);
if($r > 0){
return true;
}
A unique id is made on completion of each row.