转发模型中的请求参数/

时间:2012-01-24 14:45:28

标签: php symfony1 symfony-1.4 doctrine-1.2

有没有办法在

中进行前进
lib/model/doctrine/table.class.php?

我确实有查询。当查询返回带有$ input的false forward时。或者还有另一种方法可以做到。

谢谢!

贡纳尔

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

您也可以在行动中使用:

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

或者

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