我正在使用 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/