linux odbc

juhryniukjuhryniuk Member Posts: 6
Hi,
I've seen this topic discussed before but it was some time ago. I have a php web application running on Linux that needs to query a native Navision database. I've seen the Easysoft ODBC bridge, but I'm wondering if there are other solutions out there.

Thanks,

Comments

  • rvduurenrvduuren Member Posts: 92
    Hello,
    There are several solutions for data communication with PHP (on Linux/Apache) when using a Native Database server.

    Here's one..
    You can use the 'Navision Socket Bus Adapter' and PHP (fsockopen / fputs) can query XML.

    Navision XML Socket Server (NAS, SingleInstance CodeUnit)
    RUNTRIGGER :>> 
    CREATE(CC2);
    CREATE(SBA);
    CC2.AddBusAdapter(SBA, 0);
    SBA.ReceivingTimeout:= 20000;
    SBA.OpenSocket(8080, '');
    
    EVENTTRIGGER :>> CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
    MyFile.CREATE('c:\tmp.xml');
    
    CLEAR(InMsg);
    InMsg := InMessage;
    IsmStr := InMsg.GetStream();
    
    REPEAT
      Buff := '';
      IF IsmStr.READ(Buff, 1024) <> 0 THEN
        MyFile.WRITE(COPYSTR(Buff, 1));
    UNTIL (STRLEN(Buff) <> 1024) OR (IsmStr.EOS);
    
    MyFile.CLOSE;
    MyFile.OPEN('c:\tmp.xml');
    MyFile.SEEK(MyFile.LEN - 1);
    MyFile.TRUNC;
    MyFile.CLOSE;
    
    // Process new xml and return
    CREATE(Dom);
    Dom.load('c:\tmp.xml');
    
    IF (InMsg.ExpectReply) THEN BEGIN
      OutMsg:= InMsg.CreateReply();
      OutStr := OutMsg.GetStream();
      Dom.save(OutStr);
      OutMsg.Send(0);
    END;
    InMsg.CommitMessage;
    CLEAR(Dom);
    CLEAR(InMsg);
    

    PHP XML Webservice Client
    <?php
    $host = "127.0.0.1"; // ip of socket server
    $fp = fsockopen($host, 8080, $errno, $errstr, 5);
    if ($fp > 0) { 
      fputs($fp, "<?xml version='1.0' encoding='UTF-8'?><bookstore><book><title>The Autobiography of Benjamin Franklin</title><price>9.99</price></book></bookstore>\r\n\0");
      while (!feof($fp)) {
        $response .= fgets($fp);
      }
      fclose($fp);
      echo $response;
    }
    ?>
    

    And another one: Soap webservice. Use PHP for soap communication.
    Met vriendelijke groet, best regards,

    Rvduuren
Sign In or Register to comment.