Re: Unique id Number
| From: | Manuel Lemos | Date: | Mon, 14 Jan 2002 19:17:41 +0000 |
| Subject: | Re: Unique id Number | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11437@lists.php.net to get a copy of this message | ||
Hello,
James Mansfield wrote:
>
> OK...newbie question it must be:
> I want to add an entry into a db tb (using php obviously) and when its added
> into the db its gets a sequencially numberred id....now can I retrieve this
> id numbe rin the same php coded page as what I create the entry with? If not
> what is the best way around it? Create a unique number for the entry before
> adding it into db??
That depends on the database you are using. You need to use sequences.
Some database do not have sequences but they do have auto-incremented
fields, so it is possible to emulate a sequence object with a separate
table with a single auto-incremented field to act as a sequence.
Regardless of what database you are using, you may want to try Metabase
which is a PHP database abstraction package that supports many databases
and abstracts the concept of sequences just like I described. Metabase
is free and is available from here:
http://phpclasses.upperdesign.com/browse.html/package/20
Regards,
Manuel Lemos