带有 Obscure 驱动程序的 PHP 的 ODBC 连接字符串

发布于 2024-09-03 21:59:05 字数 287 浏览 1 评论 0原文

我正在尝试通过 ODBC 连接到数据库,但通过 Google/互联网找不到任何帮助。

我们的ERP使用OMNIS作为框架,它提供了一个ODBC驱动程序,用于在程序之外查询OMNIS的专有数据库。我已经创建了驱动程序和 DSN,但无法开始使用 PHP 操作数据或发送查询。

该驱动程序在 ODBC 连接管理器中显示为“OMNIS ODBC 驱动程序” - 我尝试了多种连接字符串,但似乎无法运行。

DSN 位于 C:\Test.dsn。该驱动程序再次显示为 OMNIS ODBC 驱动程序。非常非常感谢任何帮助。

I'm attempting to connect to a database via ODBC, and I am finding no help through Google/the internet.

Our ERP uses OMNIS as a framework, which provides an ODBC driver for querying OMNIS' proprietary database outside of the program. I've created the driver and DSN, but I cannot begin manipulating data or sending queries with PHP.

The driver appears in the ODBC connection manager as "OMNIS ODBC Driver" - I've tried a multitude of connection strings, but cannot seem to get it to go.

The DSN is located at C:\Test.dsn. Once again, the driver appears as OMNIS ODBC Driver. Any help is much, much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你如我软肋 2024-09-10 21:59:09

我能够使用这样的 DSN 进行连接:

odbc:DRIVER=OMNIS;DataFilePath=C:\import\average.df1

I was able to connect using such DSN:

odbc:DRIVER=OMNIS;DataFilePath=C:\import\average.df1
猫弦 2024-09-10 21:59:08

我最终打开将数据库克隆到 SQL 并使用该方法。尝试让 OMNIS ODBC 驱动程序工作实在是太痛苦了。

I ended up opening cloning the database to SQL and using that method. It was far too much of a pain to try to get the OMNIS ODBC Driver working.

岁月静好 2024-09-10 21:59:07

回答:

这些说明假设 Apache Web 服务器已在主机服务器上设置。

操作系统:Windows Server 2003
网络服务器:Apache 2(WAMP www.wamp.com)

1。
下载并安装适用于 Windows 非 Unicode 驱动程序的 Omnis ODBC 驱动程序 (http://www.tigerlogic.com/tigerlogic/omnis/download/tools.js

2.
为您的数据文件创建系统数据源:
-开始菜单>管理工具>数据来源
-选择“系统DSN”选项卡
-点击添加
-从驱动程序列表中选择“Omnis ODBC 驱动程序”
- 单击“完成”
- 填写数据源名称、描述和身份验证凭据
重要提示:准确记住数据源名称。这是将用于连接到数据库的数据源的名称。
-选择数据文件。
-节省
- 数据源现已在操作系统中注册并可供使用。

3.
在您的 Web 根目录中,创建一个新文件名 odbc_test.php 。

使用以下示例代码来测试数据连接。

<?php

/*My data source is named PFDSN, so that is what I will be using in this example
   Make sure you use the exact name of the data source created in step 2.
*/
$conn = odbc_connect('PFDSN',' ',' ');  //the connection to the data file
$sql = 'select * from INVOICES';    //query string
$result = odbc_exec($conn,$sql); //execute the query
$while($data[] = odbc_fetch_array($result)); //loop through the result set
odbc_free_result($result); //unallocate the result set
odbc_close($conn); //because this is good practice

print_r($data);
?>

保存并关闭文件。
导航到 http://localhost/odbc_test.php (或文件所在的任何位置)。

如果连接成功,页面将显示从发票表中提取的所有数据的转储。

如果不起作用,请检查以确保连接字符串中的 DSN 名称正确。
如果连接字符串正确但仍然不起作用,则可能是 PHP 未配置 ODBC 模块。但是,您应该注意,从 PHP 5(在 Windows 中)开始,默认情况下启用 ODBC 模块。

不幸的是,在撰写本文时,Tiger Logic 尚未提供 Linux/Unix ODBC 驱动程序。希望他们能够清醒过来并认识到 Windows 很糟糕。

结束。

Answer:

These instructions assume that Apache web server has already been set up on the host server.

Operating System: Windows Server 2003
Web Server: Apache 2 (WAMP www.wamp.com)

1.
Download and install the Omnis ODBC Driver for Windows Non-Unicode driver (http://www.tigerlogic.com/tigerlogic/omnis/download/tools.js

2.
Create a SYSTEM Data Source for your data file:
-Start Menu > Administrative Tools > Data Sources
-Choose the “System DSN” tab
-Click Add
-From the list of drivers choose “Omnis ODBC Driver”
-Click Finish
-Fill in the Data Source Name, Description, and Authentication credentials
Important: Remember the Data Source Name EXACTLY. This is the name of the data source that will be used to connect to the database.
-Choose the data file.
-Save
-The Data Source has now been registered with the operating system and is ready for use.

3.
In your web root directory, create a new file name odbc_test.php .

Use the following sample code to test the data connection.

<?php

/*My data source is named PFDSN, so that is what I will be using in this example
   Make sure you use the exact name of the data source created in step 2.
*/
$conn = odbc_connect('PFDSN',' ',' ');  //the connection to the data file
$sql = 'select * from INVOICES';    //query string
$result = odbc_exec($conn,$sql); //execute the query
$while($data[] = odbc_fetch_array($result)); //loop through the result set
odbc_free_result($result); //unallocate the result set
odbc_close($conn); //because this is good practice

print_r($data);
?>

Save and close the file.
Navigate to the http://localhost/odbc_test.php (or wherever the file is located).

If the connection was successful the page will display a dump of all the data pulled from the invoices table.

If it doesn't work, check to make sure that you have the correct DSN name in the connection string.
If the connection string is correct and it still doesn't work, there is a chance that PHP isn't configured with the ODBC module. However, you should note that since PHP 5 (in Windows) the ODBC module is enabled by default.

Tragically, at the time of this writing, Tiger Logic does not provide a Linux/Unix ODBC driver. Hopefully they come to their senses and realize that Windows sucks.

The End.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文