Re: replace??
От | Brett W. McCoy |
---|---|
Тема | Re: replace?? |
Дата | |
Msg-id | Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net обсуждение исходный текст |
Ответ на | replace?? (bboett@erm1.u-strasbg.fr (Bruno Boettcher)) |
Список | pgsql-sql |
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.
В списке pgsql-sql по дате отправления: