[eluser]Dam1an[/eluser]
Based on the definition given on the MySQL site
Quote:REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted
A very inefficient way to do it which springs to mine, is to have a replace function in the DB class, which when called check if the PK/unique fields exist, if so, create a delete clause and exacute it, and then call the insert method, else, just call insert
Pseudo code:
Code:
function replace() {
if primary_key || unique_key exists
$this->delete where pk = $pk etc
// Now we've removed any conflicting rows, so insert as normal
$this->insert();
}