Skip to content

Instantly share code, notes, and snippets.

@hh-com
Created December 13, 2018 20:28
Show Gist options
  • Save hh-com/9e9e81f251dfe36d8826922f524f4300 to your computer and use it in GitHub Desktop.
Save hh-com/9e9e81f251dfe36d8826922f524f4300 to your computer and use it in GitHub Desktop.
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