pg_last_oid
pg_last_oid
Returns the last row's OID
**pg_last_oid** PgSql\Result $result
is used to retrieve the
assigned to an inserted row.
pg_last_oid``OID
OID field became an optional field from PostgreSQL 7.2 and will
not be present by default in PostgreSQL 8.1. When the
OID field is not present in a table, the programmer must use
to check for successful
insertion.
pg_result_status
To get the value of a field in an inserted
row, it is necessary to use the PostgreSQL
function, naming the sequence whose last value is required. If the
name of the sequence is unknown, the
PostgreSQL 8.0 function is necessary.
SERIAL``CURRVAL``pg_get_serial_sequence
PostgreSQL 8.1 has a function that returns
the value of the most recently used sequence in the session. This avoids
the need for naming the sequence, table or column altogether.
LASTVAL
Opmerking: > This function used to be called .
pg_getlastoid
result
An or containing the OID assigned to the most recently inserted
row in the specified , or false on error or
no available OID.
int``string``connection
Voorbeeld: example
<?php
// Connect to the database
pg_connect("dbname=mark host=localhost");
// Create a sample table
pg_query("CREATE TABLE test (a INTEGER) WITH OIDS");
// Insert some data into it
$res = pg_query("INSERT INTO test VALUES (1)");
$oid = pg_last_oid($res);
?>
pg_query``pg_result_status