Hi I want to use a UUID
http://en.wikipedia.org/wiki/Uuid
as primary key in a table of my db, for this purpose i have put this function in After application intialized events:
function guid(){
if (function_exists('com_create_guid')){
return trim(com_create_guid(), '{}');
}else{
mt_srand((double)microtime()*10000);//opzionale per php 4.2.0 e superiore.
$charid = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45);// "-"
$uuid = //chr(123)// "{"
substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
//.chr(125);// "}"
return $uuid;
}
}
and I have used a varchar field in my db. In the visual editor I have set guid() as default value for that field, but it don't works and the field of the primary key is wrote as 0 instead of the guid(). Why I have this behaviour?
[edit]
It was my fault because in a first moment i've heavily changed the db structure and i hadn't sync the db...
[/edit]