the uid generate includes the year
This commit is contained in:
@@ -2863,20 +2863,21 @@ class G
|
|||||||
* @access public
|
* @access public
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function generateUid($prefix = '')
|
public static function generateUid($prefix = '')
|
||||||
{
|
{
|
||||||
// Ensure the prefix is exactly 3 alphabetical characters if not return default prefix
|
// Ensure the prefix is exactly 3 alphabetical characters if not return default prefix
|
||||||
if (strlen($prefix) !== 3 || !ctype_alpha($prefix)) {
|
if (strlen($prefix) !== 3 || !ctype_alpha($prefix)) {
|
||||||
$prefix = "abc";
|
$prefix = "abc";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a unique ID based on the current time in microseconds
|
// Generate a unique ID based on the current time in microseconds
|
||||||
$uniqueId = uniqid('', true);
|
$uniqueId = uniqid('', true);
|
||||||
|
|
||||||
// Remove the prefix from the unique ID and ensure it's 29 characters long
|
// Remove the prefix from the unique ID and ensure it's 29 characters long
|
||||||
$uniqueId = date('YmdH') . str_replace('.', '', $uniqueId); // Remove any dots
|
$uniqueId = date('YmdH') . str_replace('.', '', $uniqueId); // Remove any dots
|
||||||
$uniqueId = substr($uniqueId, -29); // Trim to 29 characters
|
$uniqueId = substr($uniqueId, -30); // Trim first 30 characters (to start with the year)
|
||||||
|
$uniqueId = substr($uniqueId, 0, 29); // Trim the first 29 characters
|
||||||
|
|
||||||
// Combine the prefix with the unique ID
|
// Combine the prefix with the unique ID
|
||||||
return strtolower($prefix) . $uniqueId; // Convert prefix to uppercase
|
return strtolower($prefix) . $uniqueId; // Convert prefix to uppercase
|
||||||
}
|
}
|
||||||
@@ -6270,8 +6271,8 @@ class G
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to create a legal SQL string that you can use in an SQL statement.
|
* This function is used to create a legal SQL string that you can use in an SQL statement.
|
||||||
* The given string is encoded to an escaped SQL string, taking into account the current
|
* The given string is encoded to an escaped SQL string, taking into account the current
|
||||||
* character set of the connection.
|
* character set of the connection.
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string
|
* @return string
|
||||||
|
|||||||
Reference in New Issue
Block a user