For php, the @sbecks solution works perfectly. I will only refine the link to a specific post, so as not to search. Here it is:
As for protection against a possible UUID repeat (I understand that the probability is extremely small, but there is an option to completely exclude such an event), I plan to solve this by using additional steps in the server action:
- UUID Generation will not be done while inserting a record, but before. The generation will be in a while loop, which will check whether the new uuid matches the existing ones in the database. If there is a match, the loop will repeat generation until a unique uuid is generated.
- at the stage of inserting a record, the value of the already generated and verified uuid from step 1 will simply be inserted into the field.
In this case, we will get 100% protection from possible UUID duplication.