35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace User;
|
||
|
|
||
|
use Core\Db;
|
||
|
|
||
|
class Reputation
|
||
|
{
|
||
|
private array $r;
|
||
|
|
||
|
public function __construct(int $userid)
|
||
|
{
|
||
|
$this->r = Db::getRow(
|
||
|
'select *,
|
||
|
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
|
||
|
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
|
||
|
from rep where id = ?', [$userid]
|
||
|
);
|
||
|
|
||
|
if (empty($this->r)) {
|
||
|
Db::sql('insert into rep (id) value (?)', [$userid]);
|
||
|
$this->r = Db::getRow(
|
||
|
'select *,
|
||
|
(repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep,
|
||
|
(nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep
|
||
|
from rep where id = ?', [$userid]
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function get(): array
|
||
|
{
|
||
|
return $this->r;
|
||
|
}
|
||
|
}
|