Re: Ventanas
| From: | Antonio Mármol Albert | Date: | Wed, 08 Nov 2000 10:42:35 +0000 |
| Subject: | Re: Ventanas | ||
| References: | 1 2 3 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-3443@lists.php.net to get a copy of this message | ||
> En postgresql creo que si que hay una funcion que sirve para averiguar
> el "id" del ultimo registro insertado. Yo utilizo esto:
>
>
> <?php
>
> // Hacemos el INSERT
> $sql = "INSERT.......";
> $result = pg_exec($database, $sql);
>
> // Averiguamos el OID. Esto _creo_ que es un identificador
> // interno que utiliza postgres para identificar a cada
> // registro
> $lastoid = pg_getlastoid($result);
>
> // Luego hacemos una consulta para ver a que registro
> // corresponde ese OID
> $sql = "SELECT id FROM tabla WHERE OID=$lastoid";
Se me ha olvidado mencionar, que OID no lo he defenido yo cuando cree la
tabla. Es un campo "oculto". Todas las tablas tienen un campo OID en
opstgresql.
>
> ...
>
> ?>
>
> id es de tipo SERIAL (se auto incrementa)
>
> http://php.net/manual/function.pg-getlastoid.php
--
Antonio Mármol Albert ( toni@infurma.es )