Re: [PHP-DB] Re: About retrieving auto increment value
Hi, Thanks all, I will do it with php function. -- Marc Soler Marc Soler wrote: 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 I *think* you have to do this in the same script. I would suggest using mysql_insert_id() (in PHP) on the same page where you inserted and pass it into the page that needs it. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: About retrieving auto increment value
Marc Soler wrote: 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 I *think* you have to do this in the same script. I would suggest using mysql_insert_id() (in PHP) on the same page where you inserted and pass it into the page that needs it. -- paperCrane Justin Patrin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php