pdo dbf 文件和查询

pdo dbf files and queries

大家好,我有一个使用 .dbf 文件存储数据的应用程序,我想 运行 对这些文件进行一些查询。问题是我不知道如何......我已经与支持人员讨论过它,他们告诉我我可以使用 ODBC 驱动程序或专用于 visual foxpro Ole DB 的驱动程序。根据我在 google 似乎支持到 php 5.2 或类似版本。 你能帮我弄清楚该怎么做吗?我已经 google 转了一圈,但找不到任何可以帮助我的东西。

编辑

$excelFile = realpath('C:\db\article.dbf');
$excelDir = dirname($excelFile);
$dsn = "DRIVER={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=C:\db\article.dbf;DefaultDir=$excelDir;Exclusive=NO;collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;";
$conn=odbc_connect($dsn,"","");
$sql = "SELECT * FROM articole.dbf";
$result = odbc_exec($conn, $sql);

错误:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC dBase Driver] External table is not in the expected format., SQL state S1000 in SQLExecDirect in E:\public_html\odbc\index.php on line 7

你有SQL服务器吗?您可以为 DBF 文件创建一个 linked 服务器。看看这个 link:

Linked Server

另请参阅这些 link 使用 ODBC 或 OLE DB 查询 DBase 或 Foxpro 表:

Dbase ODBC

Foxpro OleDB