Edit report at https://bugs.php.net/bug.php?id=57716&edit=1
ID: 57716
Updated by: php-bugs@lists.php.net
Reported by: cshaulis at bear dot com
Summary: PDO_ODBC: bindParam reports int as varchar
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: PDO ODBC
Operating System: Windows
PHP Version: 5.2.1
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-09-30 08:42:31] cmb@php.net
I cannot reproduce this with PHP 7.3 and the ODBC driver for SQL
server. Can anybody else?
------------------------------------------------------------------------
[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