ID: 46523 Updated by: [email protected] Reported By: mckameh2 at armadillo dot fr -Status: Open +Status: Feedback Bug Type: PDO related Operating System: Vista PHP Version: 5.2.6 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ Previous Comments: ------------------------------------------------------------------------ [2008-11-08 19:44:44] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46523&edit=1
