Answer the question
In order to leave comments, you need to log in
How unique is the id generated from the md5 hash of the string?
Theoretical question: you need to generate a unique id, based on the title of the news. Without hesitation, they washed down such a bike, but wondered, with millions of articles with unique titles, will the id generated in a similar way remain unique?
$string = md5('Some unique string');
echo $string.'<br>';
$string= preg_replace('~[^0-9]+~','',$string);
echo (int) $string.'<br>';
//result
//eb939f7a375f5520b090e49396e8393e
//9223372036854775807
Answer the question
In order to leave comments, you need to log in
IMHO, do as you wrote
There is a separate varchar 32 field for the hash in the database, there is MD5 from the title and you put an index in the database on this field
The search will be very fast
There is hardly a chance to catch a collision by accident in millions. ( https://stackoverflow.com/a/288519)
If you don't strip anything from the hash, of course, why are you removing letters?
ID != only numbers
In general, there is no sense in the undertaking, then take uniqid() or mt_rand().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question