-1
我必須在php中使用uniqid()生成自動會話ID,但我必須將其存儲在MSSQL數據庫中。但我無法將其轉換爲uniqueidentifier類型。將PHP中隨機生成的隨機ID轉換爲mssql中的uniqueidentifier
<?php
//set the random id length
$random_id_length = 10;
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or/and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first 10 characters from the $rnd_id
$rnd_id = substr($rnd_id,0,$random_id_length);
echo "Random Id: $rnd_id" ;
echo "<br>";
?>
這是代碼現在我想這$ rnd_id成唯一標識符類型和存儲到MSSQL數據庫
你到目前爲止嘗試過什麼?我們可以看到一些代碼嗎? – acme
好的,謝謝你告訴我們 – Jelmer