Re: [PHPLIB-DEV] cvs commit From: Alexander Aulbach (ssilk <email protected>)
Date: 01/24/00

On Mon, 24 Jan 2000, Kristian Köhntopp wrote:

}"Adam N. Thompson, MCNE" wrote:
}> > - $query = sprintf("replace into %s set p_valenc='%s', p_valpos='%s', p_val='%s', p_changed='%s' where p_sid='%s' and p_name='%s'",
}> > + $query = sprintf("replace into %s set p_valenc='%s', p_valpos='%s', p_val='%s', p_changed='%s', p_sid='%s' and p_name='%s'",
}> > $this->database_table,
}> > $this->encoding_mode,
}> > '000000',
}>
}> Firstly, the MySQL docs do not describe a REPLACE...WHERE syntax.
}
}Please check out
}http://www.mysql.com/Manual_chapter/manual_Reference.html#REPLACE
}
}The above syntax is still buggy, though. The "and" in the corrected
}statement is still wrong. The REPLACE in itself would be the
}desired behaviour, as the other databases are using an INSERT/UPDATE
}combo, which can be had with REPLACE in MySQL, saving another
}round-trip in the database.

>From the mySQL-docs:

"Replace works exactly like insert, except, that if an old record in the
table has the same value as a new record on a unique index, the old record
is delted before the new record is inserted."

Theoretically REPLACE is a little bit slower than INSERT/UPDATE, cause the
hole record is deleted instead updated.

-- 

SSilk - Alexander Aulbach - Herbipolis/Frankonia Minoris - (0931)22032

- PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>. To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in the body, not the subject, of your message.