A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.2 KiB

  1. <?php
  2. /**
  3. * @package uForum2
  4. * @file inc/models/StatisticsModel.php
  5. * @copyright 2007-2015 (c) PioDer
  6. * @link http://www.pioder.pl/
  7. * @license see LICENSE.txt
  8. **/
  9. class StatisticsModel extends Model
  10. {
  11. private $logged_users = null;
  12. public function getPostsCount()
  13. {
  14. $out = $this->select(POSTS_TABLE, 'count(post_id) AS posts_count');
  15. return $out[0]['posts_count'];
  16. }
  17. public function getTopicsCount()
  18. {
  19. $out = $this->select(TOPICS_TABLE, 'count(topic_id) AS topics_count');
  20. return $out[0]['topics_count'];
  21. }
  22. public function getUsersCount()
  23. {
  24. $out = $this->select(USERS_TABLE, 'count(user_id) AS users_count');
  25. return $out[0]['users_count'];
  26. }
  27. public function getLastRegisteredUser()
  28. {
  29. $out = $this->select(USERS_TABLE, 'user_id, nick, rank', '', 'user_id DESC', '1');
  30. return $out[0];
  31. }
  32. private function retrieveLoggedUsers()
  33. {
  34. if ($this->logged_users == null)
  35. {
  36. $this->logged_users = $this->select(LOGGED_USERS_VIEW);
  37. }
  38. }
  39. public function getLoggedUsersCount()
  40. {
  41. $this->retrieveLoggedUsers();
  42. return count($this->logged_users);
  43. }
  44. public function getLoggedUsers()
  45. {
  46. $this->retrieveLoggedUsers();
  47. return $this->logged_users;
  48. }
  49. }
  50. ?>