Re: [PHP-DB] About retrieving auto increment value

2004-06-08 Thread Ignatius Reilly
LAST_INSERT_ID() is connection-based, not table-based.

Therefore instead of:
SELECT LAST_INSERT_ID() FROM foo_table

you should do:
SELECT LAST_INSERT_ID()

HTH
Ignatius
_
- Original Message -
From: Marc Soler [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, June 07, 2004 7:42 PM
Subject: [PHP-DB] About retrieving auto increment value


 Hi

 I have the typical problem with retrieving auto increment value in
 php-mysql environment.

 I have search info in mysql page and I have found LAST_INSERT_ID()
 funtion but I don't know how to use correctly.

 I have one script that insert a row. And another script that must
 retrieve last auto_increment value for primary key on a table.

 I want something like this:

 SELECT LAST_INSERT_ID() FROM foo_table; (like curval(foo_sequence) in
postgres)

 This doesn't work.

 It's possible? Where I am wrong?

 Thanks in advance
 --
 Marc Soler

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] About retrieving auto increment value

2004-06-07 Thread Marc Soler
Hi

I have the typical problem with retrieving auto increment value in
php-mysql environment.

I have search info in mysql page and I have found LAST_INSERT_ID()
funtion but I don't know how to use correctly.

I have one script that insert a row. And another script that must
retrieve last auto_increment value for primary key on a table.

I want something like this:

SELECT LAST_INSERT_ID() FROM foo_table; (like curval(foo_sequence) in postgres)

This doesn't work.

It's possible? Where I am wrong?

Thanks in advance
-- 
Marc Soler

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] About retrieving auto increment value

2004-06-07 Thread Daniel Clark
I think you want mysql_insert_id()

http://us3.php.net/manual/en/function.mysql-insert-id.php


 I have the typical problem with retrieving auto increment value in
 php-mysql environment.

 I have search info in mysql page and I have found LAST_INSERT_ID()
 funtion but I don't know how to use correctly.

 I have one script that insert a row. And another script that must
 retrieve last auto_increment value for primary key on a table.

 I want something like this:

 SELECT LAST_INSERT_ID() FROM foo_table; (like curval(foo_sequence) in
 postgres)

 This doesn't work.

 It's possible? Where I am wrong?

 Thanks in advance
 --
 Marc Soler

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php