Re: Am I asking too much?

From: Date: Sat, 11 Oct 2003 15:35:29 +0000
Subject: Re: Am I asking too much?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-165852@lists.php.net to get a copy of this message
* Thus wrote John Taylor-Johnston (taylorjo@collegesherbrooke.qc.ca): > Any ideas? I want to avoid having two "mysql_query($sql)". I'm basically looking > for better functionality and wanting to learn how to clean up my code. > there are a couple options, the insert has a extra option, 'ON DUPLICATE KEY': http://www.mysql.com/doc/en/INSERT.html Or use the REPLACE syntax: http://www.mysql.com/doc/en/REPLACE.html Be forewarned about the REPLACE, that there may be side effects because it not only replaces on the primary key value but any UNIQUE index. For example (ingore syntax errors), create table ( id Primary Key name UNIQUE ) Data: 1, 'Name1' 2, 'Name2' replace into table (id, name) values (2, 'Name1'); I havn't tested this situation, but to me that, seems like an awkward position to be in. Curt. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/

« previous php.general (#165852) next »