0
我为我的博客创建了函数,但它无法正常工作。 控制器:错误在哪里 - 它们显示不正确的消息
$id_get = Model::factory('index')->get_id($slug);
$this->template->content = View::factory('index/article')
->set('slug', $mysql_respnse)
->set('commentars', Model::factory('index')->find_commentars($id_get));
查看:
<?php
if($commentars){
echo 'There is a commentar!';
}
else{
echo 'There is no any commentar!';
}
?>
型号:
public function get_id($slug){
$query = DB::query(Database::SELECT, 'SELECT id FROM ieraksti WHERE slug = :slug')
->parameters(array(':slug' => $slug))->execute()->as_array();
}
哪里错了吗?剧本显示'没有任何评论!',但我需要'有一个评论'。
也许在您的数据库中没有评论? –
我的数据库中有3条评论,其中artcl_id是3,博客文章ID是3. – reGative
什么是'commentar'?你的意思是“评论”和“评论”或“评论”和“评论”? – Darsstar