Search Postgresql Archives

Re: prepare, execute & oids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 02, 2006 at 09:25:43AM +0200, phazon wrote:
> I use PHP.
> When I make juste a simple insert like
> 
> Insert Into my_table (my_field) values ('value')
> 
> I get back the OID of the inserted line.
> 
> But when i use the prepareInsert fonction, I get nothing back. That's a
> pprobleme becaus i need to take the primary key of the line inserted in
> order to make post-operations.

The PHP source code has no prepareInsert function -- are you using
a third-party module?  If so then try contacting that module's
maintainer.  But as I mentioned previously and as Martijn pointed
out, OIDs aren't suitable as primary keys.  See the documentation
and FAQ:

http://www.postgresql.org/docs/8.1/interactive/datatype-oid.html
http://www.postgresql.org/docs/faqs.FAQ.html#item4.12

> I can't use the curval of a sequence because it can be the value of another
> insert made by another user.

As Martijn and Chris mentioned, currval() is safe in this respect.
Its behavior is documented and is the subject of an FAQ item:

http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html
http://www.postgresql.org/docs/faqs.FAQ.html#item4.11.3

-- 
Michael Fuhr


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux