Skip to content

Fix #44643: bound parameters ignore explicit type definitions #6973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ext/pdo_odbc/odbc_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,16 @@ static int odbc_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *p
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
/* MS Access, for instance, doesn't support SQLDescribeParam,
* so we need to guess */
sqltype = PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB ?
SQL_LONGVARBINARY :
SQL_LONGVARCHAR;
switch (PDO_PARAM_TYPE(param->param_type)) {
case PDO_PARAM_INT:
sqltype = SQL_INTEGER;
break;
case PDO_PARAM_LOB:
sqltype = SQL_LONGVARBINARY;
break;
default:
sqltype = SQL_LONGVARCHAR;
}
precision = 4000;
scale = 5;
nullable = 1;
Expand Down
22 changes: 22 additions & 0 deletions ext/pdo_odbc/tests/bug44643.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Bug #44643 (bound parameters ignore explicit type definitions)
--SKIPIF--
<?php
if (!extension_loaded('pdo_odbc')) die('skip pdo_odbc extension not available');
require 'ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
require 'ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$sql = "SELECT * FROM (SELECT 'test' = :id1) a WHERE a.test = :id2";
$stmt = $db->prepare($sql);
$id1 = 1;
$stmt->bindParam(':id1', $id1, PDO::PARAM_INT);
$id2 = 1;
$stmt->bindParam(':id2', $id2, PDO::PARAM_INT);
var_dump($stmt->execute());
?>
--EXPECT--
bool(true)