RaspberryPI – project for „Baltic Robo Battles” 11 – how to connect from php to ActianZen

  1. Easy way – using ODBC connection:

a) created 64-bit ODBC connection (System) in Windows

b) create user in your DB acc. to ODBC connection

c) use following source code:

$conn_str="dnsNameofYourDB"; $conn=odbc_connect($conn_str,'user','passwd'); 
$sql="SELECT top 10 First_Name,Last_Name FROM Person"; $rs=odbc_exec($conn,$sql);

if ($rs) 
{ 
while (odbc_fetch_row($rs)) 
{ 
echo odbc_result($rs,"First_Name"); 
echo odbc_result($rs,"Last_Name"); 
 }
 } 
odbc_close($conn);

2. proper way acc. to Actian:

You will need to download the Btrieve 2 SDK to do the build. It is available at  https://esd.actian.com/. Go to the Zen product and under Actian Zen (PSQL) SDKs, download the Btrieve 2 SDKs for Zen/PSQL. Pick either Windows or Linux, which I believe your server right now is Windows. You will also need to download SWIG and gcc.

The instructions to build the API is as follows :

Build BtrievePhp:

    $ sudo apt install swig php-dev

    $ tar -zxf Zen-SDK-Btrieve2API-linux-noarch-14.10.023.000.tar.gz

    $ cd Zen-SDK-Btrieve2API-000-linux-noarch-14.10.023/swig

    $ swig -php7 -I../include -c++ btrievePhp.swig

    $ gcc $(php-config –includes) -I../include -fpic -c btrievePhp_wrap.cxx

    $ gcc -shared -o btrievePhp.so btrievePhp_wrap.o -L/usr/local/actianzen/lib64 -lbtrieveCpp -lbtrieveC -lstdc++

    $ sudo bash

    # vi /etc/php/7.2/apache2/php.ini

     — Add these lines to the end of the file:

         extension=/home/jetson/ActianZen/BtrievePhp/Zen-SDK-Btrieve2API-000-linux-noarch-14.10.023/swig/btrievePhp.so

         include_path = „.:/usr/share/php:/home/jetson/ActianZen/BtrievePhp/Zen-SDK-Btrieve2API-000-linux-noarch-14.10.023/swig”

         display_errors = On

    # vi /etc/apache2/envvars

     — Add this line at the end of the file:

         export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/actianzen/lib64

    # service apache2 restart

    From an appropriate browser:

http://hostname

         — Search for btrievePhp.  You should find it listed under “Additional Modules”.

    # exit

Dodaj komentarz

Twój adres email nie zostanie opublikowany. Pola, których wypełnienie jest wymagane, są oznaczone symbolem *