Re: Transaction-based insert w/PHP?

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: David Fetter <david(at)fetter(dot)org>, SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: Transaction-based insert w/PHP?
Date: 2003-02-13 00:52:45
Message-ID: 200302121652.45639.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

David,

> Does fetching that OID inside a transaction automatically guarantee
> that the right thing happens?

Maybe, maybe not. Regardless, you're making an easy task hard. You'd be
better off staying away from OIDs entirely:

> INSERT INTO foo (foo_desc)
> VALUES ('too much unix!')

> -- Fetch the $foo_id, or roll back if unable.

$new_foo = currval('foo_foo_id_seq')

> INSERT INTO bar (bar_desc, foo_id)
> VALUES ('never too much unix!', $new_foo)

I'd suggest reading the docs on sequences. There is no reason for you ever to
use OIDs at all.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse sfpug by date

  From Date Subject
Next Message Dror Matalon 2003-02-13 00:59:41 Re: Transaction-based insert w/PHP?
Previous Message David Fetter 2003-02-12 20:35:07 Transaction-based insert w/PHP?