zend framework 记录

 Use the URL view helper, please 
http://naneau.nl/2007/07/08/use-the-url-view-helper-please/

  1. //视图
  2. <a href="<?php echo $this->url(array(
  3. 'controller' => 'user',
  4. 'action' => 'edit',
  5. 'id' => '123'
  6. ));?>">click me!</a>
  7. //控制器
  8. $route = new Zend_Controller_Router_Route(
  9.     'edit/:id',
  10.     array(
  11.         'controller' => 'user',
  12.         'action'     => 'edit'
  13.     )
  14. );
  15. $frontController = Zend_Controller_Front::getInstance ();
  16. $router = $frontController->getRouter(); 
  17. $router->addRoute('userEdit'$route);
  18. //视图
  19. <a href="<?php echo $this->url(array(
  20. 'id' => '123'
  21. ), 'userEdit');?>">click me!</a>
  22. //note the second parameter for the helper
  1.         //提交表单
  2.         if ($this->getRequest()->isPost() == true
  3. //不加载视图
  4.   $this->_helper->viewRenderer->setNoRender();
  5. //得到 $_GET $_POST 等参数
  6. $this->getRequest()->getParam('options_a')
  7. //数据库
  8. $config = new Zend_Config_Ini(WEB_ROOT . '/../application/config/config.ini''staging');//production staging
  9. $config_array   = $config->database->params->toArray();
  10. //采用 utf-8
  11. $config_array['driver_options'] = array(
  12.             PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8'
  13.         );
  14. $db = Zend_Db::factory($config->database->adapter,$config_array);
  15. //为所有的Zend_Db_Table对象设定默认的adapter
  16. Zend_Db_Table::setDefaultAdapter($db);
  17. Zend_Registry::set ( 'db', $db );


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值