return $row === false ? null : $row;
}
+ public function getProfileByVerificationCode(string $code): ?Profile
+ {
+ $stmt = $this->db->prepare('SELECT * FROM gamesticks WHERE verificationCode = :code');
+ $stmt->setFetchMode(PDO::FETCH_CLASS, 'Profile');
+ $stmt->execute([':code' => $code]);
+ $row = $stmt->fetch();
+ return $row === false ? null : $row;
+ }
+
public function createProfile(string $hwId): Profile
{
$stmt = $this->db->prepare(
return $this->getProfileByHardwareId($hwId);
}
+ public function updateProfile(string $hwId, array $values): ?Profile
+ {
+ $params = [
+ 'hwId' => $hwId,
+ ];
+
+ $sql = 'UPDATE gamesticks SET';
+ $sqlParts = [];
+ foreach ($values as $column => $value) {
+ $sqlParts[] = ' ' . $column . '= :' . $column;
+ $params[':' . $column] = $value;
+ }
+ $sql .= implode(', ', $sqlParts) . ' WHERE hwId = :hwId';
+
+ $stmt = $this->db->prepare($sql);
+ $stmt->execute($params);
+
+ return $this->getProfileByHardwareId($hwId);
+ }
+
protected function createTablesIfNeeded()
{
$res = $this->db->query(