At 8:26 PM -0400 9/13/08, Daniel Brown wrote:
On Sat, Sep 13, 2008 at 8:14 PM, tedd <tedd.sperling@xxxxxxxxx> wrote:
While you might think an order number should be something else, keep in mind
that an order is simply an order. It is a point in time where a customer has
agreed to purchase something and you have accepted and have cleared that
purchase for that payment through some sort of purchasing scheme.
One of the best schemes for developing a unique order number that
is not only unique to the system, but is also readily human-readable
would be to use an auto_increment value appended to a date string.
For example:
<?php
$today = date("Ymd");
$increment = $numberFromDB; // This routine would depend on your
database (MySQL, PostgreSQL, etc.)
$orderNumber = $today."-".$increment;
?>
From the above, you'd get an order number similar to 20080913-1048.
This means that it's not only unique, regardless of how many
orders come through in the same second, but ordering by time and date
is easier, and on paper, you can easily tell when an order was placed.
Nice to see you back my friend -- I was worried.
An auto-increment field in a table is unique.
While it doesn't include any time/date information, it is
automatically assigned when the transaction is confirmed (i.e.,
INSERT).
I've used both, but usually when I need a time/date stamp, I add that
somewhere else in the table.
However, these are just differences in style and not that one is
better than the other.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php