【问题标题】:Forward with request parameter in model/在模型/中使用请求参数转发
【发布时间】:2012-01-24 14:45:27
【问题描述】:

有没有办法在中进行转发

lib/model/doctrine/table.class.php?

我确实有一个问题。当查询返回带有 $input 的错误转发时。或者有其他方法吗。

谢谢!

古纳尔

【问题讨论】:

  • 前锋是什么意思?如果它重定向网络浏览器,我们不在模型内部执行此操作,最好在操作层中执行此操作

标签: php symfony1 symfony-1.4 doctrine-1.2


【解决方案1】:

不要在你的模型中这样做......在你的行动中这样做:

action.class.php:

$result = Doctrine_Core::getTable('yourtable')->find(1234); // or any query
if (!$result) // check if the result is false / empty
{
   $this->forward('default','notfound'); // specify your forwarding module/action
   or 
   $this->forward404(); // default 404 error
}

Symfony 1.4 docs on this subject

【讨论】:

    【解决方案2】:

    你也可以在你的行动中使用:

    $result = Doctrine_Core::getTable('yourtable')->find(1234); // or any query
    $this->redirectIf(!$result, '@homepage');
    

    或者

    $this->redirect404If(!$result, 'Your message');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-28
      • 1970-01-01
      • 1970-01-01
      • 2015-10-17
      相关资源
      最近更新 更多