Unless you're in a SQL transaction, you run a risk of getting the wrong ID
on a busy server unless you have a write lock on the table, which is
usually not a good thing. If you have another unique key, you can "select
max($field) from $table where unique_key=$keyvalue" but that's often not
possible.
MySQL has a "select last insert id" query (that I could never get to
function), maybe Postgre has a similar query/function that works? Even then
you need to make sure you're the only thread using the database connection
or you could get an insert Id from some other transaction (highly unlikely
but possible).
At 2006 01 31 05:32, Sigurd Nes wrote:
I have posted a patch - please have a look at it
http://savannah.gnu.org/bugs/download.php?item_id=15588&item_file_id=3346
Regards
Sigurd
> From: Sigurd Nes [EMAIL PROTECTED]
> Sent: 2006-01-31 10:58:59 CET
> To: [email protected]
> Subject: [Phpgroupware-developers] get_last_insert_id broken for
PostgreSQL 8.x
>
> The OID field is not be present by default in PostgreSQL 8.1 and
therefore the get_last_insert_id in class.db_pgsql.inc.php that relays on
pg_last_oid() won't work.
> There is a mention of a function lastval() to retrieve the last
inserted sequence - but I think this is a new function. One might have to
check for the pgsql version - and then apply the appropiate method.
>
> Or - it might be sufficient to ask for the max value of the field in
question?
>
> Anyone care to fix this?
>
> Regards
>
> Sigurd
_______________________________________________
Phpgroupware-developers mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/phpgroupware-developers
_______________________________________________
Phpgroupware-developers mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/phpgroupware-developers