You are here: Re: can this be achieved by a single mysql instruction? « PHP Programming Language « IT news, forums, messages
Re: can this be achieved by a single mysql instruction?

Posted by Rik on 07/20/07 07:56

On Fri, 20 Jul 2007 09:44:24 +0200, newbie <mitbbsmj@yahoo.com> wrote:

> I am writing a DB like this:
> ---------------------------------------------------------------------
> | id (auto_incremented filed) | foo | bar |
> ---------------------------------------------------------------------
>
> $sql_query =3D "INSERT INTO `table` (`foo`, `bar`) VALUES ('$string_1'=
,
> '$string_2')";
> mysql_query($sql_query, $db_handle);
> //how can I get id for the above inserted entry? is that possible I
> get it with a single mysql instruction?
>
>
> since each time I write a record into mysql, 'id' is incremented,
> how can I get the id that an insertion corresponds to (can I get it
> with a single mysql instruction)?

PHP:
mysql_insert_id();
MySQL:
mysql_query('SELECT LAST_INSERT_ID()');


-- =

Rik Wasmus

 

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

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