IDgen Function
The idgen function is a simple and efficient way to generate random IDs, making it useful for creating unique object IDs for each row in a database.
How idgen Works
🔹 Generates a random alphanumeric string of a specified length.
🔹 Uses a mix of uppercase letters, lowercase letters, and numbers.
🔹 Allows an optional delimiter ($delim) to be added between characters.
Example Usage
Generate a 10-character ID
$id = $sdb->idgen();
echo $id;
🔹 Output: aB3xT9wY2Q
Custom Length (15 Characters)
$id = $sdb->idgen(15);
echo $id;
🔹 Output: Xy7aT9kW3BzQmN
Adding a Delimiter ("-")
$id = $sdb->idgen(8, "-");
echo $id;
🔹 Output: A-3-K-7-T-W-9-Q-
Why Use idgen?
✅ Quick & Easy: No need to manually generate IDs.
✅ Unique & Random: Reduces the chances of collisions.
✅ Flexible: Supports different lengths and custom delimiters.
✅ Perfect for Object IDs: Assign unique IDs to database rows, API keys, or user sessions.
Conclusion
The idgen function is an efficient solution for generating random IDs. Whether you need unique identifiers for rows, objects, or tokens, idgen makes the process fast and customizable.