0

I am new to Zend. The problem i am getting is that i am not able to access resources.db.* configurations from application.ini The way i am using to access is

$application->getOptions()

. It does not shows the resource.db.* properties.

Can any one help me ?

4

2 回答 2

0

按照您询问的方式进行操作,我发现最简单的方法是在引导期间将所有内容放入注册表中:

//bootstrap.php
public function _initConfig {
   $config = new Zend_Config($this->getOptions());
   Zend_Registry::set('config', $config);
}

在应用程序的其他地方使用这些配置:

$db = Zend_Registry::get('config')->resources->db;

虽然如果您只是尝试访问在 application.ini 中注册的适配器:

$db = Zend_Db_Table::getDefaultAdapter();
于 2012-06-01T09:39:08.423 回答
0

改为这样做

$params = Zend_Db_Table::getDefaultAdapter()->getConfig(); //return associative array 
于 2012-06-01T08:14:44.117 回答