forkbb/app/Models/Stats/Load.php
2018-07-25 10:51:05 +07:00

27 lines
759 B
PHP

<?php
namespace ForkBB\Models\Stats;
use ForkBB\Models\Method;
class Load extends Method
{
/**
* Заполняет модель данными из БД
* Создает кеш
*
* @return Stats
*/
public function load()
{
$total = $this->c->DB->query('SELECT COUNT(u.id)-1 FROM ::users AS u WHERE u.group_id!=0')->fetchColumn();
$last = $this->c->DB->query('SELECT u.id, u.username FROM ::users AS u WHERE u.group_id!=0 ORDER BY u.registered DESC LIMIT 1')->fetch();
$this->model->userTotal = $total;
$this->model->userLast = $last;
$this->c->Cache->set('stats', [
'total' => $total,
'last' => $last,
]);
return $this->model;
}
}