KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am working on website that allows people to create profiles online. I was wondering if it is the right choice to use MySQL AUTO_INCREMENT ed IDs as my user ids. Also bearing in mind that I might have to duplicate the database across multiple servers one day? e.g. would you use this method for userIds on a website like Twitter or Facebook? I have tried generating userIds with PHP before. I used something like this: function generateID() { $possible = "1234567890"; $code = ""; $characters = mt_rand(7,14); $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } This gave the type of values I needed, but I always had to check from the DB if that ID does not exist yet. Isn't there a better approach?
Tags (comma-separated)
Save Edits
Cancel