我为我的博客创建了功能。
模型 -
public function get_article($nosaukums) {
$query = DB::query(Database::SELECT, 'SELECT * FROM ieraksti WHERE virsraksts = :nosaukums')
->parameters(array(':nosaukums' => $nosaukums))->execute();
return $query;
}
控制器 -
public function action_article()
{
Route::set('article', 'article/(name)', array('name' => '.+'))
->defaults(array(
'controller' => 'index',
'action' => 'article',
));
$this->template->content = View::factory('index/article')
->set('query', Model::factory('index')->get_article($nosaukums));
}
并查看 -
<?php
foreach($nosaukums as $article)
{
echo '<h3>'.$article['virsraksts'].'</h3>';
}
?>
我想访问 url - domain.com/article/name_of_article,但 domain.com/article 不起作用 - 错误HTTP_Exception_404 [ 404 ]: The requested URL article was not found on this server.
为什么我会收到此错误?