Created
December 13, 2018 20:28
-
-
Save hh-com/9e9e81f251dfe36d8826922f524f4300 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function generateUniqueId() | |
{ | |
# Zeichenvorrat | |
$zeichenvorrat = self::$zeichenvorrat; | |
$position = 0; | |
$uniqueId = ''; | |
for ($i = 0; $i < 6; $i++) | |
{ | |
$position = ($position + rand(1000, 9999)) % strlen($zeichenvorrat); | |
$uniqueId .= $zeichenvorrat[$position]; | |
} | |
# UNIQUE ID muss einzigartig sein und darf nicht bereits in der Datenbank vorhanden sein | |
$uniquIdResult = \Database::getInstance() | |
->prepare("SELECT participant_uniqueid FROM tl_training_participants WHERE participant_uniqueid like ? OR participant_personalnumber like ? ") | |
->execute( $uniqueId, $uniqueId ); | |
#->execute( '%'.$userGroupHash.'%' ); | |
if ($uniquIdResult->numRows > 0 ) | |
{ | |
$uniqueId = self::generateUniqueId(); | |
} | |
return $uniqueId; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment