dos71253
2013-08-31 02:17
浏览 164
已采纳

用于Microsoft SQL Server的PHP ODBC PDO驱动程序返回空数组或false

I have this code:

$dbh = new PDO('odbc:MSSQLServer', 'user', 'pass');

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sth = $dbh->prepare($sql);

$sth->execute();

$result = $sth->fetch(PDO::FETCH_ASSOC);        

var_dump($result);

If:

$sql = "select seri_cdser from tsica_alun_matr";

The output is:

array(1) {
    ["seri_cdser"]=>
    string(4) "3EMM"
}

But if:

$sql = "select * from tsica_alun_matr";

The output is:

SQLSTATE[22003]: Numeric value out of range: 0 [Microsoft][SQL Server Native Client 11.0]Numeric value out of range (SQLFetchScroll[0] at /usr/local/src/PDO_ODBC/odbc_stmt.c:372)

Sometimes an empty array is returned too, apparently the driver is instable.

The table tsica_alun_matr has 13 columns.

Someone knows if it is a bug with PDO driver for MS SQL Server?

图片转代码服务由CSDN问答提供 功能建议

我有这段代码:

  $ dbh = new PDO  ('odbc:MSSQLServer','user','pass'); 
 
 $ dbh-> setAttribute(PDO :: ATTR_ERRMODE,PDO :: ERRMODE_EXCEPTION); 
 
 $ sth = $ dbh->  prepare($ sql); 
 
 $ sth-> execute(); 
 
 $ result = $ sth-> fetch(PDO :: FETCH_ASSOC);  
 
var_dump($ result); 
   
 
 

如果:

  $ sql =“从tsica_alun_matr中选择seri_cdser  “; 
   
 
 

输出为:

  array(1){
 [”seri_cdser“] =  > 
 string(4)“3EMM”
} 
   
 
 

但是如果:

  $ sql  =“select * from tsica_alun_matr”; 
   
 
 

输出为:

  SQLSTATE [22003]:数值 超出范围:0 [Microsoft] [SQL Server Native Client 11.0]数值超出范围(/usr/local/src/PDO_ODBC/odbc_stmt.c:372),n 
 
 

有时也返回一个空数组,显然驱动程序是不稳定的。

tsica_alun_matr 有13列。

有人知道它是否是MS SQL Server PDO驱动程序的错误?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题