Bug #57716 [Opn->Fbk]: PDO_ODBC: bindParam reports int as varchar

From: Date: Wed, 30 Sep 2020 08:42:31 +0000
Subject: Bug #57716 [Opn->Fbk]: PDO_ODBC: bindParam reports int as varchar
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229282@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=57716&edit=1 ID: 57716 Updated by: cmb@php.net Reported by: cshaulis at bear dot com Summary: PDO_ODBC: bindParam reports int as varchar -Status: Open +Status: Feedback Type: Bug Package: PDO ODBC Operating System: Windows PHP Version: 5.2.1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: I cannot reproduce this with PHP 7.3 and the ODBC driver for SQL server. Can anybody else? Previous Comments: ------------------------------------------------------------------------ [2009-08-17 13:01:26] a at a dot com Unfortunately, it does not work even with bindParam(..., PDO::PARAM_INT). I've tried many (all?) potential solutions, but did not found any, except using convert() ------------------------------------------------------------------------ [2007-06-22 10:39:36] cshaulis at bear dot com Description: ------------ I am using the ODBC driver under Windows to connect PHP to a Sybase database. When using bindParam to bind variables to a prepared statement I receive the following error: 22018,257,[INTERSOLV][ODBC SQL Server driver][SQL Server]Implicit conversion from datatype 'VARCHAR' to 'INT' is not allowed. Use the CONVERT function to run this query. (SQLExecute[257] at ext\pdo_odbc\odbc_stmt.c:133),22018 However, I have specified that the variable is an integer and I have confirmed the variable actually contains a number. I have the same result when I don't explicitly declare the type. The database_name..table_name specifier in the SQL below is Sybase specific, but I'm including it in case it might alter the behavior of the prepare command. Reproduce code: --------------- create table test ( a int not null, b int not null, c varchar not null, d varchar not null ) $sthd = $dbhd->prepare("INSERT INTO test_db..test_tbl (c, d, a, b) VALUES (?, ?, ?, ?)"); $sthd->bindParam(1, $cvar, PDO::PARAM_STR); $sthd->bindParam(2, $dvar, PDO::PARAM_STR); $sthd->bindParam(3, $avar, PDO::PARAM_INT); $sthd->bindParam(4, $bvar, PDO::PARAM_INT); $avar = 123; $bvar = 123; $cvar = "test"; $dvar = "test"; if (!$sthd->execute()) { print(implode(',', $sthd->errorInfo()) . "\n"); } Expected result: ---------------- I expect there to be no output and no error condition set. Using the same code to insert into an SQLite database using PDO works as expected. Actual result: -------------- I receive the error message above. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=57716&edit=1

« previous php.bugs (#229282) next »