|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57716 PDO_ODBC: bindParam reports int as varchar
Submitted: 2007-06-22 10:39 UTC Modified: 2020-10-11 04:22 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: cshaulis at bear dot com Assigned: cmb (profile)
Status: No Feedback Package: PDO ODBC
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cshaulis at bear dot com
New email:
PHP Version: OS:


 [2007-06-22 10:39 UTC] cshaulis at bear dot com
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-17 13:01 UTC] 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()
 [2013-06-12 03:53 UTC]
-Summary: bindParam reports int as varchar +Summary: PDO_ODBC: bindParam reports int as varchar -Package: PDO_ODBC +Package: *General Issues
 [2013-12-05 19:36 UTC]
-Package: *General Issues +Package: PDO related
 [2014-01-01 12:42 UTC]
-Package: PDO related +Package: PDO ODBC
 [2020-09-30 08:42 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-09-30 08:42 UTC]
I cannot reproduce this with PHP 7.3 and the ODBC driver for SQL
server.  Can anybody else?
 [2020-10-11 04:22 UTC] php-bugs at lists dot php dot net
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.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Jun 07 23:03:39 2023 UTC