2014-02-28 43 views
0

我可以選擇任何其他列,但是如果我嘗試「SELECT *」或嘗試選擇列(專門設置爲xml),結果沒有任何結果,我正在運行PHP 5.4和Microsoft SQL 2008R2。當類型設置爲「xml」時,不能選擇列

如果我選擇使用Microsoft SQL Server Management Studio,它工作正常。代碼的

實施例:(返回$nservers = 1)代碼的//不是XML列

$qservers = "SELECT SourceIP FROM ARRC.dbo.tblLicenseActivation WHERE AssetID = '1000432'"; 
$rservers = mssql_query($qservers); 
$nservers = mssql_num_rows($rservers); 

實施例:(返回$nservers = 0)代碼的//一切

$qservers = "SELECT * FROM ARRC.dbo.tblLicenseActivation WHERE AssetID = '1000432'"; 
$rservers = mssql_query($qservers); 
$nservers = mssql_num_rows($rservers); 

實施例:(返回$nservers = 0 )// XML列

$qservers = "SELECT ActivationPayload FROM ARRC.dbo.tblLicenseActivation WHERE AssetID = '1000432'"; 
$rservers = mssql_query($qservers); 
$nservers = mssql_num_rows($rservers); 

示例代碼:(返回$nservers = 0)// XML +非XML列

$qservers = "SELECT SourceIP, ActivationPayload FROM ARRC.dbo.tblLicenseActivation WHERE AssetID = '1000432'"; 
$rservers = mssql_query($qservers); 
$nservers = mssql_num_rows($rservers); 
+0

顯示你的表的示例,代碼調用選擇 – Matt

+0

列的類型實際上是設置爲XML,而不是隻是XML數據列的存在。 – RogerLawrence

+0

嘗試使用[sqlsrv擴展名] [1]中的函數代替。 mssql擴展依賴於一個非常老的客戶端庫。 IIRC,它不處理XML列。 [1]:http://www.php.net/manual/en/intro.sqlsrv.php – cleong

回答

0

我不知道解決潛在的問題,但作爲一種解決方法,你可以嘗試將XML轉換爲字符串在SQL:

$qservers = "SELECT SourceIP, CONVERT(varchar(max),ActivationPayload) FROM ARRC.dbo.tblLicenseActivation WHERE AssetID = '1000432'"; 
$rservers = mssql_query($qservers); 
$nservers = mssql_num_rows($rservers); 
相關問題