错误在哪里 - 他们显示了错误的消息
我为我的博客创建了函数,但它无法正常工作。 控制器:
$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();
}
错误在哪里?脚本显示“没有任何评论!”,但我需要“有评论”。
I created function for my blog, but it not works correctly.
Controller:
$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));
View:
<?php
if($commentars){
echo 'There is a commentar!';
}
else{
echo 'There is no any commentar!';
}
?>
Model:
public function get_id($slug){
$query = DB::query(Database::SELECT, 'SELECT id FROM ieraksti WHERE slug = :slug')
->parameters(array(':slug' => $slug))->execute()->as_array();
}
Where is the mistake? The script shows 'There is no any commentars!', but I need 'There is a commentar'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不会在模型的 get_id() 方法中返回任何内容。因此 $get_id 的值为 NULL,$commentars 的值为 NULL。
You do not return anything in the get_id() method of your model. Therefor $get_id has a value of NULL and so does $commentars.