简体   繁体   English

使用PHP从SQL Server提取希腊列名称

[英]Fetching greek column names from sql server with php

I have a greek sql server 2008 database and i get the data with php to a website.The database data are nvarchar .In the connection to the server i have the character-set to utf-8 and in the html files charset="utf-8" . 我有一个希腊sql server 2008数据库,并用php将数据获取到一个网站。数据库数据为nvarchar 。在与服务器的连接中,我将字符集设置为utf-8并且在html文件中将charset="utf-8"

When i fetch data from the database everything is fine, but when i try to fetch column names with sqlsrv_field_metadata() , it shows up in the browser with questionmarks. 当我从数据库中获取数据时,一切都很好,但是当我尝试使用sqlsrv_field_metadata()来获取列名时,它会在浏览器中显示并带有问号。 If i get the column names from the view information_schema.columns they show up fine. 如果我从视图information_schema.columns获得列名,它们会很好显示。

What should i do? 我该怎么办?

Is there a way to check if the column names are nvarchar ? 有没有一种方法可以检查列名称是否为nvarchar

* UPDATE: *It turns out it is a sql server driver for php bug and it the issue has been added on Codeplex http://sqlsrvphp.codeplex.com/workitem/22417 * 更新: *事实证明,它是php错误的sql服务器驱动程序,并且此问题已在Codeplex http://sqlsrvphp.codeplex.com/workitem/22417上添加。

尝试与

sqlsrv_connect ($serverName, array('CharacterSet' => 'windows-1253'));

You should be using the mssql modules instead of the old sqlsrv library. 您应该使用mssql模块而不是旧的sqlsrv库。

To call you would use: 致电您将使用:

$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 


$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB"); 

//execute a stored procedure:
$query = "exec eCommerce.dbo.products_GET_Product_php @productId = $pid, @countryCode = " . $_SESSION['cc'] . ", @sid = ". $_SESSION['sid'];

$result = mssql_query($query);

while($row = mssql_fetch_array($result))
{ 
 $pagetitle = $row["product_name"];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM