Reputation: 4272
I'm able to connect to my DB2 database using PDO with an ODBC driver. I am able to run queries and get results, but prepared statements return nothing (with no errors).
This code:
$pdo = new PDO("odbc:thingy","user","password");
$stmt = $pdo->prepare("SELECT * FROM PROD.JMA3REP WHERE A3ANCD = 'DH 33-00'");
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
dd ($rows);
returns one record. Perfect.
This code:
$pdo = new PDO("odbc:thingy","user","password");
$stmt = $pdo->prepare("SELECT * FROM PROD.JMA3REP WHERE A3ANCD = ?");
$stmt->execute(array('DH 33-00'));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
dd ($rows);
returns an empty array.
I've also tried using named parameters (...where A3ANCD=:id) and that hasn't worked either.
I've tried fiddling with all the PDO attributes and haven't had any luck.
The code runs fine on other ODBC setups -- what voodoo happens with a mix of unixODBC, DB2, and PDO to prevent this query from running? And how to I beat it into submission?
Upvotes: 1
Views: 233
Reputation: 4272
So it seems that pdo_odbc on a 64bit linux architecture is buggy and I'm not the first to run into this:
https://stackoverflow.com/a/18535989/1676
The solution appears to be using 32bit odbc drivers.
Upvotes: 1