开发者

How to access a protected property of Zend_Db_Adapter

I've to change the value of protected $_autoQuoteIdentifiers but I don't know how开发者_运维问答.

class ZendX_Db_Adapter_Firebird extends Zend_Db_Adapter_Abstract
{
    protected $_autoQuoteIdentifiers = true;
.
.
.

Okay, I can change it directly in the class, but this couln't be the the best way.

My application.ini is:

resources.db.adapter = Firebird
resources.db.params.dbname = "/tmp/test.fdb"
resources.db.params.host = "127.0.0.1"
resources.db.params.username = sysdba
resources.db.params.password = masterkey
resources.db.params.adapterNamespace = "ZendX_Db_Adapter"

And the my Bootstrap.php is:

protected function _initDatabase()
    {
        $this->bootstrap('db');
        $db = $this->getResource('db');
        $db->setFetchMode(Zend_Db::FETCH_OBJ);
        Zend_Registry::set('db', $db);
        Zend_Db_Table_Abstract::setDefaultAdapter(Zend_Registry::get('db'));
    }

Any ideas?


Zend Reference Guide gives the answer: Reference Guide

$options = array(
    Zend_Db::AUTO_QUOTE_IDENTIFIERS => false
);

$params = array(
    'host'           => '127.0.0.1',
    'username'       => 'webuser',
    'password'       => 'xxxxxxxx',
    'dbname'         => 'test',
    'options'        => $options
);

$db = Zend_Db::factory('Firebird', $params);


Extend the Firebird class with one of your own, and setup the adapter to say 'My_Firebird' (or whatever) instead. You can change properties that way in the class (even making them configurable via the config passed in).


Are you sure you can't call $this->setAutoQuoteIdentifiers(false) on the adapter? :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜