我已經在我的application.ini文件下列Zend框架與ZFDebug,如何讓數據庫適配器
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(){ $ 自動加載= 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');
我假設不工作,因爲它連接到數據庫後,在我的引導做所有的事情。我該如何解決這個問題?