kohana-3 - Kohana ErrorException [ fatal error ]:调用未定义的方法 Request::redirect()

标签 kohana-3

我正在使用 Kohana 3.3.0 并且我有一个 Controller ,它应该将博客文章保存到数据库然后重定向到主页,我的代码如下:-

class Controller_Article extends Controller {

const INDEX_PAGE = 'index.php/article';

public function action_post() {

$article_id = $this->request->param('id');
$article = new Model_Article($article_id);
$article->values($_POST); // populate $article object from $_POST array
$article->save(); // saves article to database

$this->request->redirect(self::INDEX_PAGE);
}

文章保存到数据库,但重定向行给出了错误:-
ErrorException [ Fatal Error ]: Call to undefined method Request::redirect()

请让我知道如何进行重定向。

谢谢

最佳答案

从 Kohana 3.3 开始,您会收到异常,Request不再有方法 redirect .

您可以通过替换来修复您的示例
$this->request->redirect(self::INDEX_PAGE);

HTTP::redirect(self::INDEX_PAGE);

关于kohana-3 - Kohana ErrorException [ fatal error ]:调用未定义的方法 Request::redirect(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13088601/

相关文章:

php - 从 Kohana 3 中的查询字符串中获取值的正确方法是什么

select - Kohana3 ORM sum() 等效项

kohana - kohana orm3 中的多重插入

zend-framework - 在 zend 框架上使用 kohana ORM

mysql - Kohana3 和 MySQL : is it possible to keep related records?

Kohana 3 中的 PHP session

view - 如何在 Kohana 中渲染 View

php - HMVC 架构可以用来做什么?