Edit report at https://bugs.php.net/bug.php?id=61777&edit=1

 ID:                 61777
 Comment by:         me at andrewkehrig dot com
 Reported by:        frozen at frozen-solid dot net
 Summary:            Cannot bind parameters with pdo_odbc and SQL Server
                     Native Client 11.0
 Status:             Open
 Type:               Bug
 Package:            PDO related
 Operating System:   Ubuntu 12.04
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

I can verify this bug still occurs on php 5.3.19 and php 5.4.6 as well.

php 5.3.19 running on Windows experiences a slightly different version of this 
problem when talking to SQL Server via ODBC: bound parameters work, as long as 
you're not comparing them directly to date datatype columns (date, timestamp, 
etc) - if you are, you have to cast them manually from varchar to date, or if 
you're using a stored procedure with input parameters you have to set any date 
input parameters to varchar and allow the server to infer the datatype 
conversion when comparing the input parameter(a varchar holding a date, 
timestamp, etc) to an actual date,timestamp,etc column.


Previous Comments:
------------------------------------------------------------------------
[2013-01-30 00:43:04] paul dot posts at gmail dot com

Can confirm that patches in bug 50444 correct this issue for me as well.

------------------------------------------------------------------------
[2012-10-18 17:05:26] kraven at kraven dot org

I believe this is related to the SQLLEN.  PHP bug 5044 has a patch.

MS bug here where developer says its SQLLEN:
http://connect.microsoft.com/SQLServer/feedback/details/737751/cannot-bind-
parameters-with-php-pdo-odbc-and-sql-native-client-11-0

I applied the patches in bug 50444 and now it's working for me.

------------------------------------------------------------------------
[2012-05-15 18:59:11] burnhamrobertp at gmail dot com

Debian Squeeze 2.6.32-5-amd64
PHP 5.3.3 (also reproducible under PHP 5.4.0-3)

The test case and error information are exactly the same.

------------------------------------------------------------------------
[2012-04-19 18:45:03] frozen at frozen-solid dot net

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 this bug report at https://bugs.php.net/bug.php?id=61777&edit=1

Reply via email to