Reputation: 1391
In a project's code there's this part:
$companies = $db->fetchAll("SELECT id FROM companies where contact_person like '%num%\"". $num. "\"%'");
For example, $num = 'ЦВ123456' (ЦВ - cyrillic symbols). But in the db ЦВ is stored in unicode - \u0426\u0412
. So there are no hits. So how can I convert $num to unicode so the query becomes ...contact_person like '\u0426\u0412123456
?
Upvotes: 0
Views: 730
Reputation: 194
you can use php build in mb-convert encoding, convert your $string to the encoding used in the database , and query with the encoded value
https://www.php.net/manual/en/function.mb-convert-encoding.php
something like this
$string = "ЦВ123456";
$unicode = mb_convert_encoding($string, "utf-8", "unicode");
Upvotes: 1