ZF2-\ Zend \ Db \ Adapter \ Platform :: getQuoteIdentifierSymbol() [英] ZF2 - \Zend\Db\Adapter\Platform::getQuoteIdentifierSymbol()

查看:78
本文介绍了ZF2-\ Zend \ Db \ Adapter \ Platform :: getQuoteIdentifierSymbol()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下,我打算使用Pdo_mysql:

Code is as following, where I aim to use Pdo_mysql:

use \Zend\Db\Adapter\Adapter;
use \Zend\Db\Sql\Sql;
use \Zend\Db\Sql\Expression;    

$params = array(
    'driver'   => "Pdo_mysql",
    'host'     => &$this->Registry->config[ 'sql' ][ 'host' ],
    'username' => &$this->Registry->config[ 'sql' ][ 'user' ],
    'password' => &$this->Registry->config[ 'sql' ][ 'passwd' ],
    'dbname'   => &$this->Registry->config[ 'sql' ][ 'dbname' ]
);
$this->adapter  = new \Zend\Db\Adapter\Adapter( $params );
$this->platform = $this->adapter->getPlatform();
$this->sql      = new Sql( $this->adapter );

当我用以下方法检查标识符引号时:

And when I check identifier-quote symbol with:

print $this->platform->getQuoteIdentifierSymbol();    // Output: "

如您所见,双引号是符号.当然,这会使我的所有MySQL查询都失效,因为它用双引号()而不是前引号(`)引用所有标识符名称(表,列等).

As you can see, double quote is the symbol. This of course invalidates all MySQL queries of mine, since it quotes all identifier names (tables, columns etc) with double-quotes (") instead of forward-quote (`).

那么,为什么PDO-MySQL驱动程序改用Sql92符号?以及如何解决?

So, why PDO-MySQL driver uses Sql92 symbol instead? And how to fix that?

推荐答案

此问题的唯一解决方案是创建新的\ Zend \ Db \ Platform \ Mysql对象,并在启动连接时将其作为第二个参数传递给Adapter类. .这个问题暗示了自动的方式.为什么初始化MySQL适配器不附加MySQL平台,这是我不了解的-相反,它附加了SQL92平台.

The only solution to this problem was to create new \Zend\Db\Platform\Mysql object and pass it as second parameter to Adapter class when I initiate a connection. This question implies the automatic way of doing it. Why initializing MySQL adapter doesn't attach MySQL platform to it, is something I don't understand - instead it attaches SQL92 platform.

这篇关于ZF2-\ Zend \ Db \ Adapter \ Platform :: getQuoteIdentifierSymbol()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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