RE: [PEAR] Re: insert id
| From: | Alok K. Dhir | Date: | Thu, 24 Jan 2002 15:24:57 +0000 |
| Subject: | RE: [PEAR] Re: insert id | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-721@lists.php.net to get a copy of this message | ||
Doesn't using a mysql specific function defeat the point of using PEAR
to abstract DB calls? Is there not a "PEAR" way to do this which would
work across back end databases? If not, perhaps there should be...
In any case, with pgsql, the query is something like:
SELECT currval('sequence_name')
Where "sequence_name" is the name of the sequence.
Al
> -----Original Message-----
> From: Luc Saint-Elie [mailto:luc@saint-elie.com]
> Sent: Thursday, January 24, 2002 8:34 AM
> To: pear-general@lists.php.net
> Subject: [PEAR] Re: insert id
>
>
> At 04:28 24/01/02 -0800, Kancha Nepal wrote:
>
> >I'm using pgsql and pear. I've a table with sequence. after
> i insert a
> >row
> >into
> >the table i'd like to retreive the sequence value that has
> been used for the
> >insert operation. something like last insert id in mysql.
> How can i retrieve
> >this value using pear ??
>
> Kancha,
>
> With mysql it is :
>
> If $db is your current connection :
>
> $lastAutoIncrement = mysql_insert_id($db->connection);
>
> So I suppose you'll have to user pgsql corresponding function.
>
> Hope this helps
> Luc
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, e-mail: pear-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> pear-general-help@lists.php.net To contact the list
> administrators, e-mail: php-list-admin@lists.php.net
>