I connect to a SQL Server using like this:
$pdo = new PDO("odbc:DRIVER=ODBC Driver 17 for SQL Server;SERVER=$serverName;DATABASE=$dbName", $username, $password);
The PDO
instance is created, and I can run SQL queries with it, but sometimes I get charset related errors.
The database collation is non unicode (latin2), and I would like to get the response in UTF8. How is it possible to define it?
I was able to find some parameters like PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES ..."
but those are not available here, because I have an SQL Server.