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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 06:01:29 2024 UTC