【发布时间】:2011-08-12 20:35:02
【问题描述】:
我的 application.ini 文件中有以下内容
resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = ".."
resources.db.params.password = ".."
resources.db.params.dbname = "lsc3_base"
resources.db.isDefaultTableAdapter = true
现在完美运行,我可以查询数据库没有问题。
我正在尝试安装 ZFDebug,在我的主 bootstrap.php 文件中使用以下内容也很容易
` 受保护函数 _initZFDebug() { $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array('Variables',
'Time',
#'Auth',
'Memory',
'Registry',
'Database' => array('adapter' => $db),
'File' => array('basePath' => '/path/to/project'),
#'Cache' => array('backend' => $cache->getBackend()),
'Exception')
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
` 现在这显然给了我一个通知,说 $db undefined。
问题是我如何获得$db?
我尝试了以下方法: $db = Zend_Db_Table::getDefaultAdapter(); $db = $this->getPluginResource('db');
我假设它不起作用,因为它在完成我的引导程序中的所有事情之后连接到数据库。我该如何解决这个问题?
【问题讨论】: