From: jdavis at grantstream dot com Operating system: Linux 2.6.18-238.1.1.1.el5 x86_6 PHP version: 5.3.25 Package: ODBC related Bug Type: Bug Bug description:PDO_ODBC via unixodbc + mssql driver 11
Description: ------------ While trying to bind either a 'value' or a 'parameter' via PDO_ODBC there is an error. I can successfully perform the very same functionality via php odbc calls (odbc_connect, odbc_prepare, odbc_execute, etc...). Related to: https://bugs.php.net/bug.php?id=61777 PDO_ODBC is not allowing binding due to 64bit incompatibility. NOTE: We are running Zend Server 5.6, but I've tried under the latest 5.3 build of php without success (same error). Test script: --------------- /* This errors */ try { $dbh = new PDO("odbc:$host", $user, $pass ); echo "PDO_ODBC Connected<br>"; } catch (Exception $e) { die("Unable to connect: " . $e->getMessage()); } try { $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $fname = 'John'; $lname = 'Doe'; $sth = $dbh->prepare("insert into [User] ([TenantID],[UserID],[Email],[Active],[FirstName],[LastName]) values (9500, 3, 't...@test.com', 1, :fname, :lname)"); $sth->bindValue(':fname', $fname, PDO::PARAM_STR); $sth->bindValue(':lname', $lname, PDO::PARAM_STR); $sth->execute(); $count = $sth->rowCount(); echo "<br>Inserted ".$count." rows."; $dbh->commit(); //print_r($dbh->errorInfo()); } catch (Exception $e) { echo "<br>Failed: " . $e->getMessage(); //print_r($dbh->errorInfo(), true); $dbh->rollBack(); } /* This works $con = odbc_connect($host, $user, $pass); $stmt = odbc_prepare($con, "insert into [User] ([TenantID],[UserID],[Email],[Active],[FirstName],[LastName]) values (9500, 5, 't...@test.com', 1, ?, ?)"); $success = odbc_execute($stmt, array($fname, $lname)); echo 'Number of rows: ' . odbc_num_rows($stmt); print_r(odbc_errormsg()); odbc_close($con); */ Expected result: ---------------- PDO_ODBC Connected Inserted 1 rows. Actual result: -------------- Error msg: Failed: SQLSTATE[22001]: String data, right truncated: 0 [Microsoft][ODBC Driver 11 for SQL Server]String data, right truncation (SQLExecute[0] at /patched-php-src-5.3.14/php-5.3.14/ext/pdo_odbc/odbc_stmt.c:254) -- Edit bug report at https://bugs.php.net/bug.php?id=64828&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64828&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64828&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64828&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=64828&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=64828&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=64828&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=64828&r=needscript Try newer version: https://bugs.php.net/fix.php?id=64828&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=64828&r=support Expected behavior: https://bugs.php.net/fix.php?id=64828&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=64828&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=64828&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=64828&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64828&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=64828&r=dst IIS Stability: https://bugs.php.net/fix.php?id=64828&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=64828&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=64828&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=64828&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=64828&r=mysqlcfg