I have a table in a MySQL database, that uses UUID v1 as the primary key. The UUIDs are stored optimized, as a 16-byte string, as described in https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/ . The MYSQL data type for the column is binary(16). All UUIDs are generated the same way, using a PHP library. MySQL is v5.0.12.
I retrieve rows from the table like this:
$where = sprintf("'%s'", $bytestring_uuid);
$wpdb->get_results(
"
SELECT *
FROM $my_table
WHERE id = $where
"
);
Now this usually works, but oddly, with some UUIDs the query fails and i can't figure out why.
Here are some UUIDs the query works with (in the original format, so you can read them) :
c80615fc-e441-11e8-b328-002522a6b241
d4c94f0c-e441-11e8-9316-002522a6b241
df11cade-e441-11e8-b3a5-002522a6b241
This one fails:
27c049c4-e67f-11e8-9e6f-002522a6b241
Error log:
WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?IÄžo' at line 3 for query SELECT * FROM my_table WHERE id = 'èäAÈü³(
Any ideas what's happening?