468,785 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

Returning the id of an inserted row when using DB_DataObject->insert()with postgresql

Sam
Recently started using DB_DataObject with a Postgresql DB. Seems
pretty nice, but I am not sure if insert() is supposed to be able to
return the id of a recently returned object. It just seems to return 1
for me. I'm not really sure if DataObject gets confused because it
would like to create the sequences itself which have been created for
me automatically because I created the primary keys as serials. Or
something like that. Would at least like to hear if it's supposed to
work so I know if it's my fault that it's not working.
Nov 19 '07 #1
2 2136
On Mon, 19 Nov 2007 19:48:18 +0100, Sam <sg******@gmail.comwrote:
Recently started using DB_DataObject with a Postgresql DB. Seems
pretty nice, but I am not sure if insert() is supposed to be able to
return the id of a recently returned object. It just seems to return 1
for me. I'm not really sure if DataObject gets confused because it
would like to create the sequences itself which have been created for
me automatically because I created the primary keys as serials. Or
something like that. Would at least like to hear if it's supposed to
work so I know if it's my fault that it's not working.
http://pear.php.net/manual/en/packag...ect.insert.php
http://pear.php.net/manual/en/packag...-sequences.php
--
Rik Wasmus
Nov 19 '07 #2
Sam
Here's how I understand the situation right now:
Non-MySQL DBs use DB's nextId() and createSequence(). The sequence
info for DB says that you should only use these methods to access the
sequences, including for creation. I had used serials as data type for
my ids however, which results in a sequence automatically being
created by the DB. So I thought this could have caused some confusion.
So I removed the default value for the id in the table and got rid of
the sequence it was using as well. Now insert fails completely because
it tries to insert a NULL value into the id column. So it seems that
DB_DataObject doesn't manage to get an id at all right now.
Anyone have this working?
Nov 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by t_pet422 | last post: by
1 post views Thread by Gary Lundquest | last post: by
6 posts views Thread by Mark P | last post: by
7 posts views Thread by Milos Prudek | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.