1

是否有用于获取对Zend_Application配置资源的引用的辅助方法/对象/方法?

我知道我可以做类似的事情

$config = new Zend_Config_Ini($file, $environment);

但这将重新加载/解析配置文件。我正在寻找一种方法来查看运行中的给定配置值Zend_Application

我要解决的更大问题是我希望Zend_Queue使用与我的默认数据库资源相同的数据库设置。如果除了“获取对配置的引用,读取资源值”之外还有更多“Zend Like”的方式来实现这一点,请随时分享!

4

2 回答 2

3
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    public function run()
    {
        // make the config available to everyone
        $config = $this->getOptions();
        Zend_Registry::set('config', new Zend_Config($config));
        parent::run();
    }
}

Zend_Queue

Zend_Queue_Adapter_Db__construct中有代码,if (isset($this->_options['dbAdapter']))所以你可以做这样的事情

new Zend_Queue_Adapter_Db(array('dbAdapter' => Zend_Db_Table::getDefaultAdapter()));

因为标准Zend_Application_Resource_Db可以使用配置选项resources.db.isDefaultTableAdapter = true

或者您可以将数据库适配器放入注册表并从那里在任何地方获取它

于 2009-12-18T08:01:16.250 回答
1
Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOptions()
于 2010-07-16T01:22:05.550 回答