Search code examples
phppervasive-sql

How to connect with pervasive database via php


I need to know how can I connect with pervasive database via php.

As I know, I have to use ODBC. I configured it on my Windows 7 system and I created table in pervasive server.

This is my code, but it does not work:

$connect_string = "DRIVER={Pervasive ODBC Client Interface}; SERVERNAME=localhost; SERVERDSN=demodata;";
$conn = odbc_connect($connect_string, 'root', 'root');

Solution

  • You probably already have the ODBC drivers installed; I obtained the latest by installing the Pervasive Client from http://www.pervasive.com/database/Home/Products/PSQLv12.aspx (current version is 12).

    Then depending on 32 or 64 bit use the following connection string:

    32bit:

    $connect=odbc_connect("Driver={Pervasive ODBC Client Interface};ServerName=localhost;ServerDSN=DSNname;",
        "Username", "Password", SQL_CUR_USE_ODBC); 
    

    64bit:

    $connect=odbc_connect("Driver={Pervasive ODBC Interface};ServerName=localhost;ServerDSN=DSNname;",
        "Username", "Password", SQL_CUR_USE_ODBC); 
    

    (You can check these strings with the ODBC data source administrator on Windows, use equivalent on other operating systems).