|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-04-25 15:21 UTC] jani@php.net
[2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 01:00:01 2025 UTC |
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.