I'm trying to add UUIDs to a couple of tables, but I'm not sure what the best way to store/retrieve these would be. I understand it's far more efficient to use BINARY(16) instead of VARCHAR(36). After doing a bit of research, I also found that you can convert a UUID string to binary with:
UNHEX(REPLACE(UUID(),'-',''))
Pardon my ignorance, but is there an easy way to this with PHP and then turn it back to a string, when needed, for readability?
Also, would it make much difference if I used this as a primary key instead of auto_increment?
EDIT:
Found part of the answer:
$bin = pack("h*", str_replace('-', '', $guid));
How would you unpack it?