Fixed silly bug

Statistics for each user in user list showed comment count instead of post
count.
This commit is contained in:
Marcin Kurczewski 2013-12-23 16:43:06 +01:00
parent 306c6478b4
commit b1fb329fc7
2 changed files with 10 additions and 1 deletions

View file

@ -148,4 +148,13 @@ class UserEntity extends AbstractEntity
->where('commenter_id = ?')->put($this->id); ->where('commenter_id = ?')->put($this->id);
return Database::fetchOne($sqlQuery)['count']; return Database::fetchOne($sqlQuery)['count'];
} }
public function getPostCount()
{
$sqlQuery = (new SqlQuery)
->select('count(1)')->as('count')
->from('post')
->where('uploader_id = ?')->put($this->id);
return Database::fetchOne($sqlQuery)['count'];
}
} }

View file

@ -43,7 +43,7 @@
<div class="date-registered">Date registered: <?php echo date('Y-m-d H:i', $user->joinDate) ?></div> <div class="date-registered">Date registered: <?php echo date('Y-m-d H:i', $user->joinDate) ?></div>
<div class="fav-count">Favorite count: <?php echo $user->getFavoriteCount() ?></div> <div class="fav-count">Favorite count: <?php echo $user->getFavoriteCount() ?></div>
<div class="post-count">Post count: <?php echo $user->getCommentCount() ?></div> <div class="post-count">Post count: <?php echo $user->getPostCount() ?></div>
</div> </div>
</div> </div>
<?php endforeach ?> <?php endforeach ?>