如何在 *nix 上将 Zend Framework 2 与 MS SQL Server 一起使用?

How to use Zend Framework 2 with MS SQL Server on *nix?(如何在 *nix 上将 Zend Framework 2 与 MS SQL Server 一起使用?)
本文介绍了如何在 *nix 上将 Zend Framework 2 与 MS SQL Server 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在非 Windows 操作系统上将 ZF2 与 MS SQL Server 结合使用的规范方法是什么(如果存在)?

What, if it exists, is the canonical way to use ZF2 with MS SQL Server on a non-Windows OS?

根据我从 文档中了解到的内容,官方只支持Sqlsrv驱动,仅适用于Windows平台.

From what I can tell from the documentation, only the Sqlsrv driver is officially supported, which only works on the Windows platform.

在 ZF1 中,我们使用了 Pdo_Mssql 适配器并将 pdoType 指定为 dblib.我找不到在 ZF2 中做类似事情的任何参考.

In ZF1, we used the Pdo_Mssql adapter and specified the pdoType as dblib. I can't find any references to doing anything similar in ZF2.

显然 前一段时间有一个 Pdo\Mssql 驱动程序,它在一个主要的 重构,但我没有看到当前记录的使用 Pdo_Dblib 的方法.

Apparently there was a Pdo\Mssql driver some time ago which was removed during a major refactoring, but I don't see a currently documented way of using Pdo_Dblib.

根据上面的适配器文档,您可以将适配器配置中的驱动程序设置为 Pdo=OtherPdoDriver,但是没有关于这种用法的文档示例.这是否意味着您可以使用 Pdo=Pdo_DblibPdo=dblib 并且它会自动运行?

According to the adapter documentation above, you can set the driver in the adapter config to Pdo=OtherPdoDriver, but there's no documented examples of this usage. Does that mean you can use Pdo=Pdo_Dblib or Pdo=dblib and it will work automagically?

我发现传递了对 PDO ODBC 驱动程序的引用,这将是一个可用的替代方法,但找不到任何文档或代码引用.

I've found passing references to a PDO ODBC driver, which would be a usable alternative, but can't find any documentation or code references.

推荐答案

安装 php5-sybase.确保安装了 freetds.您应该在 /etc/freetds 下有一个名为 freetds.conf 的 conf 文件.

Install the php5-sybase. Make sure that freetds is installed. You should have a conf file under /etc/freetds called freetds.conf.

在你的 freetds.conf 文件中,你应该像这样设置你的 mssql 连接:

In your freetds.conf file you should setup your mssql connection like this:

[MyMsSqlServer]
host = symachine.domain.com
port = 5000
tds version = 5.0

然后,(此处以 ZF2 专辑教程为例)您可以像这样设置适配器:

Then, (using the ZF2 Albums Tutorial as an example here) you set up the adapter like this:

return array(
    'db' => array(
        'driver'         => 'Pdo',
        'dsn'            => 'dblib:host=MyMsSqlServer;dbname=zf2tutorial',
        'charset'        =>  'UTF-8',
        'username'       => 'username',
        'password'       => 'password',
        'pdotype'       => 'dblib',
    ),
    'service_manager' => array(
        'factories' => array(
            'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
        ),
    ),
);

看看这是否能帮助您找到任何地方并告诉我.我花了一段时间让它工作,我更乐意帮助其他有问题的人!!!

See if this gets you anywhere and let me know. I had a bitch of a time getting this to work, and I am more then happy to help anyone else that is having issues with this!!!

这篇关于如何在 *nix 上将 Zend Framework 2 与 MS SQL Server 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Does SQL Server Offer Anything Like MySQL#39;s ON DUPLICATE KEY UPDATE(SQL Server 是否提供类似于 MySQL 的 ON DUPLICATE KEY UPDATE 之类的东西)
Storing JSON in database vs. having a new column for each key(将 JSON 存储在数据库中与为每个键创建一个新列)
How to export SQL Server database to MySQL?(如何将 SQL Server 数据库导出到 MySQL?)
Emulate MySQL LIMIT clause in Microsoft SQL Server 2000(在 Microsoft SQL Server 2000 中模拟 MySQL LIMIT 子句)
SQL: Repeat a result row multiple times, and number the rows(SQL:多次重复结果行,并对行进行编号)
MySQL LIMIT clause equivalent for SQL SERVER(与 SQL SERVER 等效的 MySQL LIMIT 子句)