AIX Open Source

 View Only

PHP insert to db2 table with varlen field with blank value causes all PHP scripts to fail

  • 1.  PHP insert to db2 table with varlen field with blank value causes all PHP scripts to fail

    Posted 3 days ago

    Hello, I'm hoping this is a good discussion group to start in. Please advise.

    I running PHP on the IBM, PHP scripts are stored on the IFS, and using PDO ibm driver (ibm_db2). Both Zend Server and Websmart servers are serving PHP pages.

    I have a PHP script that inserts rows to a table that has a varying length field. If the value inserted to that field is a single space, then something in the system causes all my other PHP scripts to fail if wherever they are using a single space.  It's very odd.

    Here is an example a code snippet that triggers a failure:

            $insertSql = 'INSERT INTO JRPLIB.TESTNULL (KEYFLD, VARFLD) VALUES(:KEYFLD, :VARFLD)' . ' WITH NC';
            $stmt = $this->db_connection->prepare($insertSql);
          $stmt->bindValue(':KEYFLD', $KEYFLD, PDO::PARAM_STR);
            $stmt->bindValue(':VARFLD', ' ', PDO::PARAM_STR);
          $result = $stmt->execute();

    After that is executed, a simple statement like

    echo ' ';

    will echo a null value. 

    The majority of the PHP code we use is generated by Websmart wizards, and almost all those scripts have code that inserts a single space between SQL statement segments. Those spaces are now transformed to nulls resulting in disaster for the rest of the system. 

    Has anyone else experienced this behavior? Any idea where to look for a fix?

    Thanks.



    ------------------------------
    JAMES PANKRATZ
    ------------------------------