|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64828 PDO_ODBC via unixodbc + mssql driver 11
Submitted: 2013-05-13 15:49 UTC Modified: 2020-10-05 13:07 UTC
Avg. Score:4.4 ± 0.8
Reproduced:11 of 12 (91.7%)
Same Version:4 (36.4%)
Same OS:4 (36.4%)
From: jdavis at grantstream dot com Assigned: cmb (profile)
Status: Duplicate Package: PDO ODBC
PHP Version: 5.3.25 OS: Linux 2.6.18- x86_6
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: jdavis at grantstream dot com
New email:
PHP Version: OS:


 [2013-05-13 15:49 UTC] jdavis at grantstream dot com
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:
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 { 

$fname = 'John';
$lname = 'Doe';

$sth = $dbh->prepare("insert into [User] ([TenantID],[UserID],[Email],[Active],[FirstName],[LastName]) values (9500, 3, '', 1, :fname, :lname)");
$sth->bindValue(':fname', $fname, PDO::PARAM_STR);
$sth->bindValue(':lname', $lname, PDO::PARAM_STR);

$count = $sth->rowCount();

echo "<br>Inserted ".$count." rows.";
} catch (Exception $e) {
  echo "<br>Failed: " . $e->getMessage();
  //print_r($dbh->errorInfo(), true);

/* This works 
$con = odbc_connect($host, $user, $pass);
$stmt    = odbc_prepare($con, "insert into [User] ([TenantID],[UserID],[Email],[Active],[FirstName],[LastName]) values (9500, 5, '', 1, ?, ?)");
$success = odbc_execute($stmt, array($fname, $lname));

echo 'Number of rows: ' . odbc_num_rows($stmt);


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)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-10-05 13:07 UTC]
-Status: Open +Status: Duplicate -Package: ODBC related +Package: PDO ODBC -Assigned To: +Assigned To: cmb
 [2020-10-05 13:07 UTC]
I'm marking this as duplicate of bug #74186, since that ticket
already has been analyzed.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Mar 27 23:03:38 2023 UTC