Each row in my database needs a unique code. This code is public so I want to avoid auto increment integers that allow users to know how many rows there are. I'd also prefer not to do an MD5 hash of an auto increment integer as it could be easily reversed.
Currently, each time I insert a new row I generate an array of random codes in PHP and check the database to see if any are available for use. I insert the new row using the first available code.
This requires two database calls and I run into the possibility that all randomly generated codes are already in use.
Does MySQL have something built in where I can insert a new row and one of the columns are automatically inserted with a random, non-sequential, (hopefully short), code that is not in use.