I want to write a php a function which will create 50000 unique random alpha numeric string of length 4 and insert it into a db table. how can I do it?
Share
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.
As documented here
Edit: alternative insert manner (striping the dashes)
Edit worth mentioning:
Within one single server the UUIDs encode geographic location and precision time, along with sha-1 random values.
Thus the probability of collision only exists within separate servers (for example when merging their data sets).
So long as we don’t overflow the capacity of the geo/time slots it is guaranteed to not create duplicate values locally.
As a matter of optimisation (speed of database reads) casting the UUID to a binary(16) field (and having the column in the table to match that datatype) is faster and more compact.