[英]Can Db_Table models be used in bootstrap?
我將這段代碼寫到了我的引導程序中
public function _initRouter()
{
$pages = new Pages();
$routes = $pages->getRoutes();
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$router->addRoutes($routes);
return $router;
}
我收到以下錯誤消息“找不到頁面適配器”。
我正在使用application.ini(Zend_Application)設置數據庫連接。
問題是,如何在引導程序中使用數據庫? 用於模型等
最好的祝福,
菲利浦
在調用_initRouter函數之前,必須確保已設置數據庫。
遵循以下原則
protected function _initDb()
{
$resource = $this->getPluginResource('db');
$db = $resource->getDbAdapter();
Zend_Db_Table_Abstract::setDefaultAdapter($db);
return $db;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.