forked from flashii/eeprom
32 lines
1.1 KiB
PHP
32 lines
1.1 KiB
PHP
<?php
|
|
namespace EEPROM\Users;
|
|
|
|
use Index\Data\DbStatementCache;
|
|
use Index\Data\IDbConnection;
|
|
|
|
// restrictions and permissions should be checked with misuzu or cached or something
|
|
// size multiplier should also just be replaced with an alternate max size value for premioids, maybe based on rank?
|
|
|
|
class UsersData {
|
|
private DbStatementCache $cache;
|
|
|
|
public function __construct(IDbConnection $dbConn) {
|
|
$this->cache = new DbStatementCache($dbConn);
|
|
}
|
|
|
|
public function getUser(string $userId): ?UserInfo {
|
|
$stmt = $this->cache->get('SELECT user_id, UNIX_TIMESTAMP(user_created), UNIX_TIMESTAMP(user_restricted), user_size_multiplier FROM prm_users WHERE user_id = ?');
|
|
$stmt->addParameter(1, $userId);
|
|
$stmt->execute();
|
|
|
|
$result = $stmt->getResult();
|
|
return $result->next() ? new UserInfo($result) : null;
|
|
}
|
|
|
|
public function ensureUserExists(string $userId): void {
|
|
$stmt = $this->cache->get('INSERT IGNORE INTO prm_users (user_id) VALUES (?)');
|
|
$stmt->addParameter(1, $userId);
|
|
$stmt->execute();
|
|
}
|
|
}
|