Zend Framework 2查询中的双引号 [英] Zend Framework 2 Double Quotes in Queries

查看:64
本文介绍了Zend Framework 2查询中的双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Zend Framework 2进行应用程序开发.整个应用程序基于IBM Informix数据库.

I'm using the Zend Framework 2 for application developement. The whole application is based on a IBM Informix database.

数据库配置如下所示:

return array(
'db' => array(
    'driver'         => 'Pdo',
    'dsn'            => 'dsn:connection:string',
    'driver_options' => array(
    ),
),
'service_manager' => array(
    'factories' => array(
        'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
    ),
),
);

通过实例化Zend \ Db \ Sql \ Select对象查询数据库时,查询总是被引用,这不会发生,因为Informix不再处理查询.

When querying the database by instantiating an Zend\Db\Sql\Select object, the queries are always getting quoted, which should not happen because Informix can't handle the query anymore.

期望的查询字符串:

SELECT column1, column2 FROM table

Zend生成的查询字符串:

SELECT "column1", "column2" from "table"

经过一些研究,我发现了类似的情况,但是没有一种解决方案是可以接受的.这里的问题是,我必须传递一个Zend \ Db \ Sql \ Select对象,因此不可能通过$ dbAdapter-> query($ sql)用原始sql查询数据库.

After some research I found similar cases, but neither solution was acceptable. The problem here is, that I have to pass an Zend\Db\Sql\Select object, so querying the database with raw sql via $dbAdapter->query($sql) is not possible.

也许有一种方法可以禁用报价(例如在数据库配置中)?

Is there maybe a way to disable quotation(in the database configuration, e.g.)?

一些小费将不胜感激. 预先感谢

Some tipps would be very appreciated. Thanks in advance

推荐答案

,您可以禁用引用标识符.像这样

you can disable quoting identifiers. like this

use Zend\Db\Adapter\Adapter as DbAdapter;

// DB2 Connection
$adapter = new DbAdapter(array(
    'driver' => 'IbmDb2',
    'database' => '*LOCAL',
    'username' => '',
    'password' => '',
    'driver_options' => array(
        'i5_naming' => DB2_I5_NAMING_ON,
        'i5_libl' => 'LIB1 LIB2 LIB3'
    ),
    'platform_options' => array('quote_identifiers' => false)
);

摘自Zend Framework文档.

taken from Zend Framework documentation.

这篇关于Zend Framework 2查询中的双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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