You are here: Re: How to get the value of an auto_increment primary key after an insert ? « PHP SQL « IT news, forums, messages
Re: How to get the value of an auto_increment primary key after an insert ?

Posted by George on 09/11/06 18:43

On 11 Sep 2006 08:01:34 -0700, NC wrote...
>
>Pugi! wrote:
>>
>> In a mysql database you have a table, with an integer
>> as primary key. You've specified auto_increment.
>> Using PEAR to access your database how do you
>> get hold of the value of the primary key of a row you
>> just inserted ?
>
>Call mysql_insert_id():
>
>http://www.php.net/mysql_insert_id
>
>Cheers,
>NC
>

Thanks for the information. I wasn't sure if that would work on older versions
of MySQL since the mysql_insert_id function in MySQL wasn't added until v4.1.2.
Wasn't sure if PHP used mysql_insert_id or last_insert_id with its function. If
it does create a problem, I think you can run a query with a statement like
this...

"SELECT LAST_INSERT_ID()"

George
--
Help a community by participating in ours!
NewsGuy.Com - http://newsguy.com/charity.asp

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация