[英]A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$comment_count Filename: blog/index.php Line Number: 35
My line number 35 of view/blog/index.php is as:我的 view/blog/index.php 的第 35 行是:
<a href="<?php echo base_url().'post/'.$post->entry_id.'#comments';?>" class="comments">Comments (<?php echo $post->comment_count;?>)</a>
I have made a column in table comment as comment_id
still its not working我在表注释中创建了一个列,因为
comment_id
仍然不起作用
and in my model/blog_model.php
it is a function as:在我的
model/blog_model.php
它是一个函数:
$count = array(
'comment_count' => $total_count,
);
Thanks in advance提前致谢
You are mixing up your notations.你正在混淆你的符号。 Question isnt very clear but if you have set an array index like...
问题不是很清楚,但是如果您设置了一个数组索引,例如...
$count = array(
'comment_count' => $total_count,
);
And I assume passing $count
as $post
into your view and trying to access like this...我假设将
$count
作为$post
传递到您的视图中并尝试像这样访问......
$post->comment_count
It wont work as this is not array notation.它不会工作,因为这不是数组表示法。 Correct would be..
正确的应该是..
$post['comment_count']
If $post
and $count
are different objects then you need to do..如果
$post
和$count
是不同的对象,那么你需要做..
$count['comment_count']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.