我的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>
我在表注释中做了一列,作为comment_id
仍然不能工作
,在我的model/blog_model.php
中,它是一个函数:
$count = array(
'comment_count' => $total_count,
);
Thanks in advance
你把记号弄混了。问题不是很清楚,但是如果你设置了一个数组索引,比如…
$count = array(
'comment_count' => $total_count,
);
我假设将$count
作为$post
传递到您的视图中,并尝试像这样访问…
$post->comment_count
它不起作用,因为这不是数组符号。正确的是…
$post['comment_count']
如果$post
和$count
是不同的对象,那么你需要做…
$count['comment_count']