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?