Received: from chapelperilous.net (chapelperilous.net [216.254.44.199]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id eBJD5I678597 for ; Tue, 19 Dec 2000 08:05:19 -0500 (EST) (envelope-from bmccoy@chapelperilous.net) Received: from localhost (bmccoy@localhost) by chapelperilous.net (8.9.3/8.9.3) with ESMTP id IAA17712; Tue, 19 Dec 2000 08:08:09 -0500 Date: Tue, 19 Dec 2000 08:08:09 -0500 (EST) From: "Brett W. McCoy" To: Bruno Boettcher cc: Subject: Re: replace?? In-Reply-To: <20001219133752.C9283@erm1.u-strasbg.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200012/211 X-Sequence-Number: 545 On Tue, 19 Dec 2000, Bruno Boettcher wrote: > actually i look up if the corresponding entry exists (comparing > user-name and field-name) if yes i update, if no i insert.... > > this isn't very appealing, but i couldn't find another way yet to make > this shorter... > > would be nice if something like the following existed: > > replace settings set auser='toto',field='lang',data='fr' where > auser='toto' and field='lang'; > > update settings set auser='toto',field='lang',data='fr' where > auser='toto' and field='lang' REPLACE; What is the difference between replacing data and updating data in this sense? What you might want to do with your array (which in PHP can also function as a hash, with string indices) is create a wrapper class that kind of emulates a hash tied to the DB like one might do in Perl, so that whenever you 'store' a value in the array (via a method), it will automagically update or insert into the underlying database. PHP doesn't do ties explicitly, but you can emulate this behaviour with a PHP class. -- Brett http://www.chapelperilous.net/~bmccoy/ --------------------------------------------------------------------------- The price of greatness is responsibility.