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

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

am 19.11.2007 19:48:18 von 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.

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

am 19.11.2007 20:09:42 von luiheidsgoeroe

On Mon, 19 Nov 2007 19:48:18 +0100, Sam wrote:

> 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/package.database.db-dataobject .db-dataobject.insert.php
http://pear.php.net/manual/en/package.database.db.intro-sequ ences.php
--
Rik Wasmus

Re: Returning the id of an inserted row when using

am 22.11.2007 18:43:19 von 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?