Re: last OID and connections?
От | Adam Haberlach |
---|---|
Тема | Re: last OID and connections? |
Дата | |
Msg-id | 20011017121823.A8332@newsnipple.com обсуждение исходный текст |
Ответ на | last OID and connections? ("Johnny Jørgensen" <johnny@halfahead.dk>) |
Список | pgsql-php |
On Wed, Oct 17, 2001 at 03:27:17PM +0200, "Johnny Jørgensen" wrote: > Once I get a current project to production state, I'm going to get a heap of users performing updates simultaneously throughthe same update.php, and that raises a few questions: > > 1. will pg_getlastoid() return the last oid inserted *by this user*, *on this page*, *on this connection*, or is therea possibility for them to get mixed up, because the database gets a connection from the same user (php), and reusesconnections or something? If you pass it the result object from your last insert, it should give an oid unique to that insert. I usually do the insert, the immediately read the row back with a select for the pg_lastoid() in order to get the pkey. A little wanky, but it seems to be the way to do it. > e.g. If a user changes his profile, and an administrator changes some other row at the same time? If they are through seperate connections, they should be completely different. > 2. I find oid's pretty clever, but are they good for unique keys? It seems, foreign key constraints won't use oid's inthe current release, should i use serials instead? Don't use them for anything persistent except for large objects. Use serials as primary keys. -- Adam Haberlach | Computer science has the unfortunate characteristic adam@newsnipple.com| that many of the pioneers of the field are still | alive and doing research. | -- Adam Rifkin ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
В списке pgsql-php по дате отправления: