php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46523 bindValue does not use data_type parameter correctly
Submitted: 2008-11-08 19:44 UTC Modified: 2009-05-03 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mckameh2 at armadillo dot fr Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.6 OS: Vista
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mckameh2 at armadillo dot fr
New email:
PHP Version: OS:

 

 [2008-11-08 19:44 UTC] mckameh2 at armadillo dot fr
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-25 15:21 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 02:01:32 2025 UTC