I have a php function using mysql query UNIX_TIMESTAMP() to create a unique transaction number, but I found that if the function loop in same time, it will generate the same transaction number for Case 1, using Case 2 is not a good way for huge loop.
1.I am using transaction number is for sorting same transaction date in table list.
2.My transaction table is using UUID as PK, because data cross DB.
Desire answer is like below and unique.
TransNo = 1397533879.20290
PHP Version 5.3
Mysql Version 5.5
E.g. Function Loop 3 times
Case 1 :
SELECT UNIX_TIMESTAMP() as TransNo;
Output :
1397533879
1397533879
1397533879
Case 2 :
SELECT UNIX_TIMESTAMP() as TransNo, SLEEP(1);
Output :
1397533879
1397533880
1397533881