Im looking for how to generate a unique id that will remain unique for one year. I use uniqid() function but I’ve heard that there is a chance for duplicates, so I do this:
$id = rand(0,1000) . uniqid();
Will this remain unique for a whole year?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only way to be sure you have a unique Id in your data set is to test for it.
This is a simple example of how you might flow this in a simple application. I’m sure there is probably a way to do this SQL as well (but I don’t know SQL that well).
Alternatively you could just let the database start at 1 and assign each record a unique value for it’s ID.
You failed to mention your purpose so these suggestions are a best guess.
Good Luck.