|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-08-17 13:01 UTC] a at a dot com
[2013-06-12 03:53 UTC] ssufficool@php.net
-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] mike@php.net
-Package: *General Issues
+Package: PDO related
[2014-01-01 12:42 UTC] felipe@php.net
-Package: PDO related
+Package: PDO ODBC
[2020-09-30 08:42 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2020-09-30 08:42 UTC] cmb@php.net
[2020-10-11 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 01:00:01 2025 UTC |
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.