从Linux上的PHP进行广泛的ODBC访问? [英] Pervasive ODBC access from PHP on Linux?

查看:81
本文介绍了从Linux上的PHP进行广泛的ODBC访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我一个在远程Linux机器上从PHP查询Pervasive PSQL数据库的示例吗?

Can anyone give me an example of querying a Pervasive PSQL database from PHP on a remote Linux machine?

普遍的说法是PHP可以访问它,但是他们的示例使用Windows COM对象,而Linux上没有此对象,并且它们具有第一个用于下载的"PHP DTO Extensions 1"链接实际上是指向一堆ASP .NET脚本的链接. ,甚至根本不是PHP: 无处不在的PHP示例

Pervasive claims PHP can access it, but their examples use Windows COM objects, which isn't available on Linux, and the first "PHP DTO Extensions 1" link they have for download actually links to a bunch of ASP .NET scripts, and isn't even PHP at all: Pervasive PHP Examples

推荐答案

我将让Pervasvive知道他们需要更改示例.我在那里有一些联络人.至于在Linux机器上使用PSQL,您没有提到要使用哪个版本的PSQL,但是您需要用于Linux的PSQL客户端.这是我之前用来测试从Linux(和WIndows)上的PHP到PSQL服务器的连接性的示例.在odbc_connect中,"Demodata"是ODBC DSN名称.其他两个参数是用户名和密码.您将需要在PHP中编译(或启用)ODBC.

I'll let Pervasvive know they need to change the sample. I've got some contacts there. As for using PSQL from a Linux box, you don't mention what version of PSQL you are using but you'll need the PSQL client for Linux. Here's a sample I've used before to test connectivity from PHP on Linux (and WIndows) to a PSQL server. In the odbc_connect, the "Demodata" is the ODBC DSN name. The other two parameters are user name and password. You would need to compile (or enable) ODBC in PHP.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>PHP Sample</TITLE>
</HEAD>
<BODY>
<?php
$conn=odbc_connect("Demodata","","",""); 
$sql="select * from class";
$rs=odbc_exec($conn,$sql);  
echo "<table border=1>\n";
$numfields = odbc_num_fields($rs);
for($i=1;$i<=$numfields;$i++){
    $fn=odbc_field_name($rs,$i);
    echo "<th>$fn</th>";
}
echo "\n";
while(odbc_fetch_row($rs)){ 
    echo "<tr>\n";
    for($i=1;$i<=$numfields;$i++){
       $fv=odbc_result($rs,$i);
       echo "<td>$fv</td>";
    }   
    echo "</tr>\n";
} 
echo "</table>\n";
echo "<p>Number of Fields: $numfields</p>\n";
?>
</BODY>
</HTML>

这篇关于从Linux上的PHP进行广泛的ODBC访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆