我在我的網站有一個部分,我確實需要計算特定帖子的評論數。我實際上已經構建了一個用於檢索評論數據庫表(函數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