Use the URL view helper, please
http://naneau.nl/2007/07/08/use-the-url-view-helper-please/
http://naneau.nl/2007/07/08/use-the-url-view-helper-please/
- //视图
- <a href="<?php echo $this->url(array(
- 'controller' => 'user',
- 'action' => 'edit',
- 'id' => '123'
- ));?>">click me!</a>
- //控制器
- $route = new Zend_Controller_Router_Route(
- 'edit/:id',
- array(
- 'controller' => 'user',
- 'action' => 'edit'
- )
- );
- $frontController = Zend_Controller_Front::getInstance ();
- $router = $frontController->getRouter();
- $router->addRoute('userEdit', $route);
- //视图
- <a href="<?php echo $this->url(array(
- 'id' => '123'
- ), 'userEdit');?>">click me!</a>
- //note the second parameter for the helper
- //提交表单
- if ($this->getRequest()->isPost() == true)
- //不加载视图
- $this->_helper->viewRenderer->setNoRender();
- //得到 $_GET $_POST 等参数
- $this->getRequest()->getParam('options_a')
- //数据库
- $config = new Zend_Config_Ini(WEB_ROOT . '/../application/config/config.ini', 'staging');//production staging
- $config_array = $config->database->params->toArray();
- //采用 utf-8
- $config_array['driver_options'] = array(
- PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8'
- );
- $db = Zend_Db::factory($config->database->adapter,$config_array);
- //为所有的Zend_Db_Table对象设定默认的adapter
- Zend_Db_Table::setDefaultAdapter($db);
- Zend_Registry::set ( 'db', $db );