Open-source Languages & Tools for z/OS

 View Only
  • 1.  PHP PDO database query returning NULLs

    Posted 07-27-2016 12:02

    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



  • 2.  RE: PHP PDO database query returning NULLs

    Posted 07-29-2016 12:32

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



  • 3.  RE: PHP PDO database query returning NULLs

    Posted 07-29-2016 13:53

    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!



  • 4.  RE: PHP PDO database query returning NULLs

    Posted 08-02-2016 18:25

    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



  • 5.  RE: PHP PDO database query returning NULLs

    Posted 08-05-2016 10:55

    Great! Thank you for your help.