PHP MySQL searchin in database with a field having latin1_bin collation
I have a database table on a server where I can't change any configuration and one misconfiguration is the a mix og UTF-8, latin1_bin and latin1_swedish_ci. When searching the field having latin1_bin and it contains Swedish characters like ÅÄÖ it seemed hard to get it to work properly. However I found a soultion finally that worked for us.
$city = 'Örebro';//even works with lower case 'örebro'
$query->where('UPPER(ps.city) = UPPER(?)', mb_strtoupper($city, 'UTF-8'));
//ps.city in the DB is 'Örebro' latin1_bin