From:
Operating system: Ubuntu 12.04
PHP version: 5.3.10
Package: PDO related
Bug Type: Bug
Bug description:Cannot bind parameters with pdo_odbc and SQL Server Native
Client 11.0
Description:
------------
When trying to bind parameters to a prepared statement, bindValue() and
bindParam() both return false with the error code HY004, [SQL Server Native
Client
11.0]Invalid SQL data type (SQLBindParameter[0] at /build/buildd/php5-
5.3.10/ext/pdo_odbc/odbc_stmt.c:379)
It does not matter whether you pass in PDO::PARAM_STR or PARAM_INT or no
data type
specification, the error is the same every time.
Using parameters with odbc_connect() and odbc_prepare() work as expected,
so the
issue is directly related to PDO, not to ODBC or Microsoft's driver.
Test script:
---------------
$db = new PDO('odbc:sqltest', 'wwwuser', 'btsb');
$strSql = 'select top 10 * from oltmaster where titleno = :no';
$q = $db->prepare($strSql);
var_dump($q->bindValue(':no', '029803'));
var_dump($q->errorInfo());
Expected result:
----------------
boolean true
array
0 => string '' (length=0)
1 => int 0
2 => string ' ((null)[0] at (null):0)' (length=24)
3 => string '' (length=0)
Actual result:
--------------
boolean false
array
0 => string 'HY004' (length=5)
1 => int 0
2 => string '[Microsoft][SQL Server Native Client 11.0]Invalid SQL data
type
(SQLBindParameter[0] at
/build/buildd/php5-5.3.10/ext/pdo_odbc/odbc_stmt.c:379)'
(length=143)
3 => string 'HY004' (length=5)
--
Edit bug report at https://bugs.php.net/bug.php?id=61777&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=61777&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=61777&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=61777&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=61777&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=61777&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=61777&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=61777&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=61777&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=61777&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=61777&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=61777&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=61777&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=61777&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=61777&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=61777&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=61777&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=61777&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=61777&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=61777&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=61777&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=61777&r=mysqlcfg