pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brett W. McCoy <bmccoy@chapelperilous.net>
To: Bruno Boettcher <bboett@erm1.u-strasbg.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: replace??
Date: Tue, 19 Dec 2000 08:08:09 -0500 (EST)
Message-ID: <Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net> (raw)
In-Reply-To: <20001219133752.C9283@erm1.u-strasbg.fr>

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.




view thread (6+ messages)  latest in thread

Message-ID: <Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net>
Permalink:  ../Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net/
Also on:    postgresql.org/message-id/Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bmccoy@chapelperilous.net, bboett@erm1.u-strasbg.fr
  Subject: Re: replace??
  In-Reply-To: <Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net>
  References: <20001219133752.C9283@erm1.u-strasbg.fr> <Pine.LNX.4.30.0012190801580.17179-100000@chapelperilous.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox