note 101657 deleted from function.uniqid by danbrown
| From: | danbrown@php.net | Date: | Mon, 03 Jan 2011 17:20:28 +0000 |
| Subject: | note 101657 deleted from function.uniqid by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175417@lists.php.net to get a copy of this message | ||
Note Submitter: gearond at sbcglobal dot net
Reason: bad code
----
This makes a COMB UUID, for the purpose of UUIDs as PRIMARY keys in databases.
/* requires installation of ubuntu 'php5_uuid' module
* see this URL: http://www.informit.com/articles/printerfriendly.aspx?p=25862
* else, use a search engine and look up "comb uuid", or "sequential uuid"
*
* returns a guid with the last 12 chars representing the HEX value of time
* allow better clustering of database index pages and faster performance
* while still using UUIDs
*
*/
function make_comb_uuid(){
uuid_create(&$v4);
uuid_make($v4, UUID_MAKE_V4);
uuid_export($v4, UUID_FMT_STR, &$v4String);
$var=gettimeofday();
return substr($v4String,0,24).substr(dechex($var['sec'].$var['usec']),0,12);