对于我当前的项目,我想从数据库动态加载路由。为了实现这一点,我需要在加载实际控制器之前获取这些结果(当然)。
我想通过将结果添加到引导程序来实现此目的。但是,我在这个主题上尝试的每一个教程(极少数)都没有用。
人们建议打电话
$this->bootstrap('db');
但是,此资源似乎不存在。
我的application.ini中有db资源。
任何可以使这项工作的东西?
非常感谢!
答案 0 :(得分:0)
在Bootstrap
班级
public function _initDynamicRoutes()
{
// bootstrap FrontController resource
$this->bootstrap('frontController');
// bootstrap DB resource
$this->bootstrap('db');
// get the router from the front controller
$router = $this->getResource('frontController')->getRouter();
// if you need the Zend_Db resource for direct calls...
$db = $this->getResource('db');
// fetch route data, add to $router
}