php.net |  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
Votes:12
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-238.1.1.1.el5 x86_6
Private report: No CVE-ID: None
 [2013-05-13 15:49 UTC] jdavis at grantstream dot com
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, 'test@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, 'test@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)


Patches

Pull Requests

History

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