I already have an auto-inc ID field but I also need a field to store a unique reference number for each record.
At the moment I have a function which generates a random 8 digit number - this works fine but obviously there is still a possibilty of a duplicate number being created.
I could always check the latest reference number and add 1 to it, but is there any other way?
The problem is uniqid generates a 13 digit number - I prefer to use 8 digits or less as it’s a customer reference number - when the customer calls they don’t have to read out 13 numbers.