Skip to main content

Hi,

I’m having an issue with database queries in one of my applications since migrating to Rocket PHP. When running the below code, I used to get a record from the DB2 table split into the $subject, $authorname, $authorid, and $message variables; but now I’m getting NULL for each one. Here is the code that is experiencing the issue:

$query = "SELECT SUBJECT,AUTHOR,USERID,BODY FROM $_SESSION[DATABASE] WHERE NUMBER=$tm";
putenv("DSNAOINI=$_SESSION[DB2INI]");
$dbh = new PDO($_SESSION['DB2SSID'],$_SESSION['APPID'],$_SESSION['APPPW'],array('PDO_ATTR_PERSISTENT' => false));
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sth=$dbh->prepare($query);
$sth->execute();
$sth->bindColumn(1,$subject);
$sth->bindColumn(2,$authorname);
$sth->bindColumn(3,$authorid);
$sth->bindColumn(4,$message);
$sth->fetch(PDO::FETCH_BOUND);
$sth = NULL;
$dbh = NULL;

I’ve tried using the actual column names instead of binding them by number and that didn’t help. I also tried converting from PDO::FETCH_BOUND to PDO::FETCH_ASSOC which fixed the first 3 columns, but it introduced a new problem where the 4th column wouldn’t come back because it is a CLOB. I think I need to keep using the bindColumn() and PDO::FETCH_BOUND to get the CLOB to retrieve properly. I’m not getting any bad completion codes after the database handle or statement objects are created.

Thank you for your help,

Chris

Hi,

I’m having an issue with database queries in one of my applications since migrating to Rocket PHP. When running the below code, I used to get a record from the DB2 table split into the $subject, $authorname, $authorid, and $message variables; but now I’m getting NULL for each one. Here is the code that is experiencing the issue:

$query = "SELECT SUBJECT,AUTHOR,USERID,BODY FROM $_SESSION[DATABASE] WHERE NUMBER=$tm";
putenv("DSNAOINI=$_SESSION[DB2INI]");
$dbh = new PDO($_SESSION['DB2SSID'],$_SESSION['APPID'],$_SESSION['APPPW'],array('PDO_ATTR_PERSISTENT' => false));
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sth=$dbh->prepare($query);
$sth->execute();
$sth->bindColumn(1,$subject);
$sth->bindColumn(2,$authorname);
$sth->bindColumn(3,$authorid);
$sth->bindColumn(4,$message);
$sth->fetch(PDO::FETCH_BOUND);
$sth = NULL;
$dbh = NULL;

I’ve tried using the actual column names instead of binding them by number and that didn’t help. I also tried converting from PDO::FETCH_BOUND to PDO::FETCH_ASSOC which fixed the first 3 columns, but it introduced a new problem where the 4th column wouldn’t come back because it is a CLOB. I think I need to keep using the bindColumn() and PDO::FETCH_BOUND to get the CLOB to retrieve properly. I’m not getting any bad completion codes after the database handle or statement objects are created.

Thank you for your help,

Chris

Hi Chris,
Please identify your exact tool version per instructions here and I will have someone look into this.
Best,
-Peter


Hi,

I’m having an issue with database queries in one of my applications since migrating to Rocket PHP. When running the below code, I used to get a record from the DB2 table split into the $subject, $authorname, $authorid, and $message variables; but now I’m getting NULL for each one. Here is the code that is experiencing the issue:

$query = "SELECT SUBJECT,AUTHOR,USERID,BODY FROM $_SESSION[DATABASE] WHERE NUMBER=$tm";
putenv("DSNAOINI=$_SESSION[DB2INI]");
$dbh = new PDO($_SESSION['DB2SSID'],$_SESSION['APPID'],$_SESSION['APPPW'],array('PDO_ATTR_PERSISTENT' => false));
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sth=$dbh->prepare($query);
$sth->execute();
$sth->bindColumn(1,$subject);
$sth->bindColumn(2,$authorname);
$sth->bindColumn(3,$authorid);
$sth->bindColumn(4,$message);
$sth->fetch(PDO::FETCH_BOUND);
$sth = NULL;
$dbh = NULL;

I’ve tried using the actual column names instead of binding them by number and that didn’t help. I also tried converting from PDO::FETCH_BOUND to PDO::FETCH_ASSOC which fixed the first 3 columns, but it introduced a new problem where the 4th column wouldn’t come back because it is a CLOB. I think I need to keep using the bindColumn() and PDO::FETCH_BOUND to get the CLOB to retrieve properly. I’m not getting any bad completion codes after the database handle or statement objects are created.

Thank you for your help,

Chris

Here is the info:

Tool: php
Version: 5.4.4
Build Number: 0003

The results of a “php -v” are:
PHP 5.4.4 (cgi-fcgi) (built: Nov 19 2015 03:37:51) (DEBUG)

Thanks!


Here is the info:

Tool: php
Version: 5.4.4
Build Number: 0003

The results of a “php -v” are:
PHP 5.4.4 (cgi-fcgi) (built: Nov 19 2015 03:37:51) (DEBUG)

Thanks!

Hi Chris,
I confirm via our QA team that this is a known problem and it will be investigated by a developer soon. I will reply again to this post when there is news.
Regards,
-Peter


Hi,

I’m having an issue with database queries in one of my applications since migrating to Rocket PHP. When running the below code, I used to get a record from the DB2 table split into the $subject, $authorname, $authorid, and $message variables; but now I’m getting NULL for each one. Here is the code that is experiencing the issue:

$query = "SELECT SUBJECT,AUTHOR,USERID,BODY FROM $_SESSION[DATABASE] WHERE NUMBER=$tm";
putenv("DSNAOINI=$_SESSION[DB2INI]");
$dbh = new PDO($_SESSION['DB2SSID'],$_SESSION['APPID'],$_SESSION['APPPW'],array('PDO_ATTR_PERSISTENT' => false));
$dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$sth=$dbh->prepare($query);
$sth->execute();
$sth->bindColumn(1,$subject);
$sth->bindColumn(2,$authorname);
$sth->bindColumn(3,$authorid);
$sth->bindColumn(4,$message);
$sth->fetch(PDO::FETCH_BOUND);
$sth = NULL;
$dbh = NULL;

I’ve tried using the actual column names instead of binding them by number and that didn’t help. I also tried converting from PDO::FETCH_BOUND to PDO::FETCH_ASSOC which fixed the first 3 columns, but it introduced a new problem where the 4th column wouldn’t come back because it is a CLOB. I think I need to keep using the bindColumn() and PDO::FETCH_BOUND to get the CLOB to retrieve properly. I’m not getting any bad completion codes after the database handle or statement objects are created.

Thank you for your help,

Chris

Great! Thank you for your help.