Skip site navigation (1) Skip section navigation (2)

Re: replace??

From: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
To: Bruno Boettcher <bboett(at)erm1(dot)u-strasbg(dot)fr>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: replace??
Date: 2000-12-19 13:08:09
Message-ID: Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net (view raw or flat)
Thread:
Lists: 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.


In response to

  • replace?? at 2000-12-19 12:37:52 from Bruno Boettcher

pgsql-sql by date

Next:From: Frank JoerdensDate: 2000-12-19 13:17:58
Subject: Re: Tree structure table normalization problem (do I need atrigger?)
Previous:From: Bruno BoettcherDate: 2000-12-19 12:37:52
Subject: replace??

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group