Overcoming PHP/SQL Server encoding inconsistency

59 Views Asked by At

Following this blog post, I managed to connect to a MSSQL Server form PHP/CentOS machine. I can get result, however I can not use comparison in the where clause. I should be due to different encoding. Here is my code:

$db = new PDO("odbc:USERS", "username", "password");
$sql = "SELECT top 1 name FROM user where name='تست'";
$stmt = $db->prepare($sql);
$result = $stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
var_dump($row);

Also using $name = mb_convert_encoding('تست', 'utf16'); (also 'UCS-2LE' encoding) Was not helpful. How config PHP/MSSQL to use a single encoding?

0

There are 0 best solutions below