Stats.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\User;
  10. use ForkBB\Models\Action;
  11. class Stats extends Action
  12. {
  13. /**
  14. * Возвращает данные по статистике пользователей
  15. */
  16. public function stats(): array
  17. {
  18. $vars = [
  19. ':gid' => FORK_GROUP_UNVERIFIED,
  20. ];
  21. $query = 'SELECT COUNT(u.id)
  22. FROM ::users AS u
  23. WHERE u.group_id!=?i:gid';
  24. $total = (int) $this->c->DB->query($query, $vars)->fetchColumn();
  25. $query = 'SELECT u.id, u.username
  26. FROM ::users AS u
  27. WHERE u.group_id!=?i:gid
  28. ORDER BY u.registered DESC
  29. LIMIT 1';
  30. $last = $this->c->DB->query($query, $vars)->fetch();
  31. return [
  32. 'total' => $total,
  33. 'last' => $last,
  34. ];
  35. }
  36. }