Esempio n. 1
0
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;
}
Esempio n. 2
0
/**
 * A temporary method of generating GUIDs of the correct format for our DB.
 * @return String contianing a GUID in the format: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
 *
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
*/
function create_guid()
{
    global $log;
    $log->debug("Entering create_guid() method ...");
    $microTime = microtime();
    list($a_dec, $a_sec) = explode(" ", $microTime);
    $dec_hex = sprintf("%x", $a_dec * 1000000);
    $sec_hex = sprintf("%x", $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);
    $log->debug("Exiting create_guid method ...");
    return $guid;
}
Esempio n. 3
0
 /**
  * Returns a DB specific piece of SQL which will generate GUID (UUID)
  * This string can be used in dynamic SQL to do multiple inserts with a single query.
  * I.e. generate a unique Sugar id in a sub select of an insert statement.
  * @return string
  */
 public function getGuidSQL()
 {
     $guidStart = create_guid_section(9);
     return "'{$guidStart}-' || HEX(generate_unique())";
 }
Esempio n. 4
0
 /**
  * Returns a DB specific piece of SQL which will generate GUID (UUID)
  * This string can be used in dynamic SQL to do multiple inserts with a single query.
  * I.e. generate a unique Sugar id in a sub select of an insert statement.
  * @return string
  */
 public function getGuidSQL()
 {
     $guidStart = create_guid_section(3);
     return "'{$guidStart}-' || sys_guid()";
 }