Добрый день!
Помогите пожалуйста разобраться - не получается вывести статьи из БД ...
Вот код:
Model_ArticleКод:
...
public function get_one($id)
{
$query = DB::select('title', 'content_full', 'author', 'date')
->from($this->_tableArticles)
->where('id', '=', $id)
->execute();
return $query;
}
Controller_ArticleКод:
public function action_index()
{
$id = Request::current()->param('id');
if($id)
{
$article = array();
$content = View::factory('pages/article')
->bind('article', $article);
$query_article = new Model_Article();
$article = $query_article->get_one($id);
$this->template->content = $content;
}
else
$content = 'This page has been deleted or don't exists.';
$this->template->content = $content;
}
article.php (view)Код:
<?php foreach($article as $key): ?>
<h1><?php echo $article['title']; ?></h1><br />
<p><?php echo $article['content_full']; ?></p><br />
<i>Author</i> - <?php echo $article['author']; ?><br />
<i>Date</i> - <?php echo $article['date']; ?>
<?php endforeach; ?>
</div>