function uuid_uuid in Universally Unique IDentifier 6
Generate and return an Universally Unique IDentifier (UUID).
Return value
An UUID, made up of 32 hex digits and 4 hyphens.
See also
http://www.ietf.org/rfc/rfc4122.txt
http://php.net/manual/en/function.uniqid.php#65879
10 calls to uuid_uuid()
- UUIDFunctionalityTestCase::testChangedSettingNodeUUID in ./
uuid.test - Verify uuid behavior with changed settings. All settings are forced to disabled, then a node is created (with no UUID). Then settings are enabled, and the node is resaved, which should trigger UUIDs being created.
- UUIDFunctionalityTestCase::testDisabledNodeUUID in ./
uuid.test - Verify uuid behavior for nodes.
- UUIDFunctionalityTestCase::testEnabledNodeUUID in ./
uuid.test - Verify uuid behavior for nodes.
- uuid_comment in ./
uuid.module - Implementation of hook_comment().
- uuid_nodeapi in ./
uuid.module - Implementation of hook_nodeapi().
File
- ./
uuid.module, line 363 - Main module functions for the uuid module.
Code
function uuid_uuid() {
// If we're not using postgres, the database will give us a UUID.
if ($GLOBALS['db_type'] != 'pgsql') {
return db_result(db_query('SELECT UUID()'));
}
// If the function provided by the uuid pecl extension is available, use that.
if (function_exists('uuid_create')) {
return uuid_create(UUID_TYPE_DEFAULT);
}
// Fall back to generating a Universally Unique IDentifier version 4.
// Base on http://php.net/manual/en/function.uniqid.php#65879
// The field names refer to RFC 4122 section 4.1.2.
return sprintf('%04x%04x-%04x-%03x4-%04x-%04x%04x%04x', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 4095), bindec(substr_replace(sprintf('%016b', mt_rand(0, 65535)), '01', 6, 2)), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}