2天前,SQL Admin將MSSQL從2008升級到2008 R2。 在此升級之前,我使用FreeTDS的MSSQL工作,但升級後無法讀取存儲過程中的任何輸出參數。所以我安裝了官方的ODBC驅動程序從微軟站點的Linux(我使用的是CentoOS 64) 現在: 我可以連接,做一個簡單的查詢,但我不能捕獲存儲過程的任何輸出參數,也不能catch查詢輸出:CENTOS PHP PDO ODBC MSSQL 2008 r2
select OutputString from tTableOutput where ID = 5
其中OuptutString包含大的xml。
我嘗試PDO,ODBC和所有不工作。 如果我使用PDO:
$result = $db->query("select OutputString from tTableOutput with(nolock) where ID = 5");
foreach ($result as $row) {
print_r($row);
}
我得到:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[01004]: String data, right truncated: 0 [Microsoft][ODBC Driver 11 for SQL Server]String data, right truncation (SQLFetchScroll[0] at /builddir/build/BUILD/php-5.3.3/ext/pdo_odbc/odbc_stmt.c:528
)
怎樣才能增加長度的限制?
如果我使用ODBC:
$conn = odbc_connect($dataSource,$user,$password);
$sql = "select OutputString from tTableOutput where ID = 5";
$rs=odbc_exec($conn,$sql);
odbc_binmode ($rs, ODBC_BINMODE_PASSTHRU);
odbc_longreadlen ($rs, 0);
if (!$rs){
exit("Error in SQL");
}
while (odbc_fetch_row($rs)){
print_r(odbc_result($rs, "OutputString"));
}
odbc_close($conn);
我得到:
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4294967293 bytes)
爲什麼這個查詢需要4GB內存?
我將不勝感激任何幫助