2012-02-21 36 views

回答

4

你可能只是這樣稱呼它

$next_meeting->id = create_guid(); 

例如在邏輯鉤。該函數本身放置在/include/utils.php文件中。

當然,你必須新生成的豆與

$next_meeting->save(); 
+0

謝謝erop的回答.. – sabna 2012-02-23 11:25:59

+0

「當你決定哪個答案是最通過點擊答案左側的複選框大綱,將其標記爲已接受的答案。「 (來自[stackoverflow.com/faq#howtoask](http://stackoverflow.com/faq#howtoask))。 – DIF 2012-03-06 09:21:41

1

節省您需要將其調用方式如下:

$Module_Bean->new_with_id = true; 
$Module_Bean->id = create_guid(); 

請注意,如果您使用create_guid功能,然後指定你自己的ID 「new_with_id」也需要設置。您可以在此路徑尋找功能:包括\ utils.php中

以下是函數體:

function create_guid() 
{ 
    $microTime = microtime(); 
    list($a_dec, $a_sec) = explode(' ', $microTime); 

    $dec_hex = dechex($a_dec * 1000000); 
    $sec_hex = dechex($a_sec); 

    ensure_length($dec_hex, 5); 
    ensure_length($sec_hex, 6); 

    $guid = ''; 
    $guid .= $dec_hex; 
    $guid .= create_guid_section(3); 
    $guid .= '-'; 
    $guid .= create_guid_section(4); 
    $guid .= '-'; 
    $guid .= create_guid_section(4); 
    $guid .= '-'; 
    $guid .= create_guid_section(4); 
    $guid .= '-'; 
    $guid .= $sec_hex; 
    $guid .= create_guid_section(6); 

    return $guid; 
} 
相關問題