0

Hello
I would like to create a reference field.
I would like it ti have a fixed number of charaters/numbers, just like the videos reference of YouTube.
Is there a mysql/php function to handle that? I mean a function that generates a unique string that doesn't exist already in the table.

Help appreciated
Thank you

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by tchiky
0

Lookup the UUID() MySql function.

Hi
Thanks for the tip.
I have noticed that UUID function returns a always a different string,
but i would like to generate one with a fixed length - 10.
I now i could substring the returned string but that is contrary to what i want - the substring may already exists and i want to generate always a new one. Any idea?

0

Hi
I just used a md5 hash of a input variable and then a substr
of 10 characters. Then i make select on the table to check if is a unique id;
if yes Ok; if no just warn the user to change the input variable.

0

I did almost the same but with:
$hash = date(DATE_RFC822).$input_user_var;
$hash=md5($hash);
then the substr();

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.