A possible solution:

Make a composite primary key where the first field is the date and the
second field would be of type enumeration (A..Z, in ascending order).
Then use MAX(<second field>) WHERE <first field> = <today's date> to
figure out the next primary key.

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.


> -----Original Message-----
> From: Kevin Murphy [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 07, 2006 5:06 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: Incremental Date Based ID
> 
> Well, part of the issue is that I want to be able to use this as part
> of the link:
> 
> /news.php?article=2006-03-05a
> /news.php?article=2006-03-05b
> 
> which i will eventually do a htacess rewrite to make it look like
> 
> /news/2006-03-05a.php
> /news/2006-03-05a.php
> 
> I don't think I can do that with just the Unix timestamp.
> 
> On Mar 7, 2006, at 4:56 PM, Al wrote:
> 
> > Kevin Murphy wrote:
> >> I'm trying to set up an ID field that works like this for news
> >> articles that are posted to a website.
> >> 2006-03-05a
> >> 2006-03-05b
> >> I know how to generate the date, and I am pretty sure I can
> >> generate the letter code based on counting the number of rows and
> >> then assigning the next letter (we will never have more than 26 in
> >> a day... usually its closer to 1 or 2 per day).
> >> The problem is if there has been something deleted.
> >> 2006-03-05a
> >> 2006-03-05c
> >> If I then Count the rows with this date I get an answer of 2, and
> >> so the next letter should be "c" but there already is a "c"
> >> because "b" got deleted.
> >> So, is there any way of generating this style ID number
> >> automatically?
> >> --Kevin Murphy
> >> Webmaster - Information and Marketing Services
> >> Western Nevada Community College
> >> www.wncc.edu
> >> (775) 445-3326
> >
> >
> > Why not simply use the Unix time stamp. time() If more than one can
> > arrive within the same second, append a letter.
> >
> > If users need to see the key, use date() to decode it for them
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

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

Reply via email to