About creating a solution for order numbers
E-commerce and e-commerce system more and more, I believe that the order number problem is the most common problem of this kind of system, but today still want to talk about.
These days because of the job need to take over another colleague developed a trading system, originally used by the Uniqid () function generated. In theory, there will be no duplication, but for some special reason, you have to re-create an order number generation function
Copy the Code code as follows:
/**
* Generate a unique order number 20110809111259232312
* 2011-Year Date
* 08-month
* 09-Date
* 11-hour
* 12-minute
* 59-sec
* 2323-μs
* 12-Random value
* @return String
*/
Public Function Trade_no () {
List ($usec, $sec) = Explode ("", Microtime ());
$usec = substr (Str_replace (' 0. ', ', $usec), 0, 4);
$str = rand (10,99);
Return date ("Ymdhis"). $usec. $str;
}
The above is the whole content of this article, I hope you can enjoy.