我在我的网站有一个部分,我确实需要计算特定帖子的评论数。我实际上已经构建了一个用于检索评论数据库表(函数getComments)中的所有数据的函数。PHP性能和冗余
评论数据库表结构是:id(PK)| authorId | datetime | postId |文字
现在,因为我只需要指望他们(的意见),我在想,如果在服务器资源/冗余的期限是更好地使用:
$comments=new Comment();
$comments->getComments();
echo count($comments);
还是我最好再建功能(除了 'getComments'),如:
function countComments($postid)
{
//count comments per post
}
感谢
卢卡
这何尝不是Zend的谈话;) – 2011-05-17 09:27:29
是的,我不得不改变它更一般的PHP谈话。 – luca 2011-05-17 09:39:42