如何访问 Zend_Db_Adapter 的受保护属性
我必须更改 protected $_autoQuoteIdentifiers 的值,但我不知道如何更改。
class ZendX_Db_Adapter_Firebird extends Zend_Db_Adapter_Abstract
{
protected $_autoQuoteIdentifiers = true;
.
.
.
好吧,我可以直接在课堂上更改它,但这可能不是最好的方法。
我的 application.ini 是:
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"
我的 Bootstrap.php 是:
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'));
}
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Zend 参考指南给出了答案: 参考指南
Zend Reference Guide gives the answer: Reference Guide
使用您自己的类扩展 Firebird 类,并将适配器设置为“My_Firebird”(或其他名称)。您可以在类中以这种方式更改属性(甚至可以通过传入的配置来配置它们)。
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).
您确定无法在适配器上调用
$this->setAutoQuoteIdentifiers(false)
吗? :)Are you sure you can't call
$this->setAutoQuoteIdentifiers(false)
on the adapter? :)