问题
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');
回答1:
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).
回答2:
Use this connection string:
$connect=odbc_connect("Driver={Pervasive ODBC Engine Interface};ServerName=localhost;ServerDSN=DSNname;",
"Username", "Password", SQL_CUR_USE_ODBC);
来源:https://stackoverflow.com/questions/22917908/how-to-connect-with-pervasive-database-via-php