From:             mckameh2 at armadillo dot fr
Operating system: Vista
PHP version:      5.2.6
PHP Bug Type:     PDO related
Bug description:  bindValue does not use data_type parameter correctly

Description:
------------
The function odbc_stmt_param_hook() in pdo_odbc\odbc_stmt.c does not use
the data_type parameter correctly if the call to SQLDescribeParam()does not
succeed.
Instead of converting in this case the data_type parameter from
PDO:PARAM_* to the matching SQL type, it sets in most cases the SQL type to
SQL_LONGVARCHAR.

Remark: The data_type parameter should IMHO have absolute priority over
SQLDescribeParam(). In effect, if the data_type parameter is specified,
than there is no point in even calling SQLDescribeParam(). Especially since
the ODBC database server may not be able to assign a correct data-type to
the place-holder ('?').

Reproduce code:
---------------
gDBObject = new PDO('odbc:DATABASE', '', '');
$x = 1;
$lvStmt = $gDBObject->prepare('SELECT col1 FROM Table WHERE col2 = ?');
$lvStmt->bindValue(1,$x, PDO::PARAM_INT);
$lvStmt->execute();

But you do need to use an ODBC database that will not return in this case
a SQL_SUCCESS return-value for SQLDescribeParam() !

Expected result:
----------------
I would expect the following request to be sent to the ODBC database
server:
SELECT col1 FROM Table WHERE col2 = 1

Actual result:
--------------
The following request is sent to the ODBC database server:
SELECT col1 FROM Table WHERE col2 = '1'

which is a syntax error, since col2 is integer.

-- 
Edit bug report at http://bugs.php.net/?id=46523&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=46523&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=46523&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=46523&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=46523&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=46523&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=46523&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=46523&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=46523&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=46523&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=46523&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=46523&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=46523&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=46523&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=46523&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=46523&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=46523&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=46523&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=46523&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=46523&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=46523&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=46523&r=mysqlcfg

Reply via email to