views:

21

answers:

1

Hi,

I wrote this piece of code to my bootstrap

public function _initRouter()
{
    $pages = new Pages();
    $routes = $pages->getRoutes();

    $front = Zend_Controller_Front::getInstance();
    $router = $front->getRouter();
    $router->addRoutes($routes);

    return $router;
}

I get the following error message 'No adapter found for Pages'.

I'm using application.ini (Zend_Application) to setup DB connection.

The question is, how can i use database in bootstrap? For use in models etc.

Best Regards,

Philip

A: 

You have to make sure that your database is setup before you call the _initRouter function.

Something along the lines of

protected function _initDb()
{
    $resource = $this->getPluginResource('db');
    $db = $resource->getDbAdapter();
    Zend_Db_Table_Abstract::setDefaultAdapter($db);
    return $db;
}
Themodem
Use the code tag. The way it is your code is hard to read. Its the button with the 00100101
Iznogood
Ok i'll try it out
Phliplip