From 4d6378a34c23d30e0208f291b2a655f72e8866c9 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Sun, 27 Apr 2025 22:17:04 +0000 Subject: [PATCH] the uid generate includes the year --- gulliver/system/class.g.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 4fdd03da3..d8ccb380d 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -2863,20 +2863,21 @@ class G * @access public * @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 if (strlen($prefix) !== 3 || !ctype_alpha($prefix)) { $prefix = "abc"; } - + // Generate a unique ID based on the current time in microseconds $uniqueId = uniqid('', true); - + // Remove the prefix from the unique ID and ensure it's 29 characters long $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 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. - * The given string is encoded to an escaped SQL string, taking into account the current + * 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 * character set of the connection. * @param string $string * @return string