作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个
$noOfcomment = DB::select("SELECT COUNT(comment) as cs FROM comments WHERE placeid='$pid->placeid'");
但我不知道如何在 View 中打印结果?
最佳答案
The
select
method will always return anarray
of results.
print_r($noOfcomment);
要打印计数:
echo $noOfcomment[0]->cs;
要在 View 中打印结果,您必须传递一个变量:
return View::make('viewName', array('count' => $noOfcomment[0]->cs));
然后在你的 View 中打印结果:
<?php echo $count; ?>
要获取更多有关 Laravel 数据库的详细信息,请查看:
http://laravel.com/docs/4.2/database
要了解更多有关 Laravel 中 View 的详细信息,请查看:
关于php - 如何在 View 中打印 sql 计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33805056/
我是一名优秀的程序员,十分优秀!