[英]PHP PDO SQL Query alias UTF-8
I'm trying to get alias table as UTF-8, in a simple select query, but i get gibberish in the alias column name.我试图在一个简单的选择查询中将别名表作为 UTF-8 获取,但我在别名列名中得到了胡言乱语。
Here is my code:这是我的代码:
include("adodb5/adodb.inc.php");
//create an instance of the ADO connection object
$conn =&ADONewConnection ('sqlsrv');
//define connection string, specify database driver
$conn->Connect('xxx.xxx.x.xxx:1400', 'user', 'password', 'DbName');
//declare the SQL statement that will query the database
$query = "select firstName as 'שם פרטי' from users";
$rs = $conn->execute($query);
//execute the SQL statement and return records
$arr = $rs->GetArray();
print_r($arr);
And this is my result:这是我的结果:
Array
(
[0] => Array
(
[�� ����] => יעקב
[0] => יעקב
)
)
The results r UTF-8, but i cant get the alias of the column in UTF-8.结果 r UTF-8,但我无法在 UTF-8 中获得该列的别名。
any ideas?有任何想法吗?
You can add the UTF-8 decoding in the connection string like:您可以在连接字符串中添加 UTF-8 解码,例如:
$dbConn = new PDO('mysql:host=localhost;dbname=' . $dbname . ';charset=UTF8',
$username, $password);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.