8 Replies Latest reply on Jun 17, 2009 3:12 AM by martinjconnolly

    [FB4] PHP Data Service - how to use with DB2?

    martinjconnolly

      Hi,

      I've tried to follow the tutorial that wires a datagrid to a PHP service. However I need to get data from DB2 rather than MySQL. I have created the service and populated an array using db2_fetch_object - the service works as I can call it with a simple test PHP script. However if I try to use this in the Data Service dialogs, when I get to the point of creating a return type for my getAllItems() call, it returns an error telling me to look in my server logs. My PHP logs say nothing.... Does this work with DB2? As far as I know the data returned by a db2_fetch_object is pretty close to the mysql version.

      Thanks

       

      NB my PHP code is as follows:

       

      public function getAllItems() {
              $rows=Array();
              $query_cust = ".....SQL in here.............";
              $conn = connectLocal();
              if ($conn) {
                  //error_log("Got connection");
                  $stmt = db2_prepare($conn, $query_cust);
                  $thisrow=0;
                  db2_execute($stmt,array(0));
                  while($row = db2_fetch_object($stmt)){
                      $rows[$thisrow]=$row;
                      //error_log($row->CUSTNUM);
                      //error_log($rows[$thisrow]->CUSTNUM);
                      $thisrow++;
                  }
                  db2_close($conn);
              }
             
              return $rows;
          }